From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 959681F852 for ; Sun, 23 Jan 2022 21:38:01 +0000 (UTC) Received: from localhost ([::1]:56002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBkYi-00076s-RM for e@80x24.org; Sun, 23 Jan 2022 16:38:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYd-000738-Rk for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:37:58 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:39760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYb-00007A-UG for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:37:55 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 85C5E1F9F4 for ; Sun, 23 Jan 2022 21:37:46 +0000 (UTC) From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH 1/9] deduplicate and freeze pathnames + metadata Date: Sun, 23 Jan 2022 21:37:38 +0000 Message-Id: <20220123213746.21085-2-e@80x24.org> In-Reply-To: <20220123213746.21085-1-e@80x24.org> References: <20220123213746.21085-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.71.152.64; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" This ought to save some memory for dtas-player and dtas-readahead users with multiple instances of the same track(s) on their track list. --- bin/dtas-readahead | 7 +++---- lib/dtas/edit_client.rb | 4 ++-- lib/dtas/mcache.rb | 4 ++-- lib/dtas/player.rb | 6 +++--- lib/dtas/sigevent/fiddle_efd.rb | 4 ++-- lib/dtas/source/sox.rb | 2 +- lib/dtas/track.rb | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index 3f46b95..996142c 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -141,7 +141,7 @@ def do_open(path) buf << fp.read(fp.size - 4) Dir.chdir(File.dirname(path)) do yml = DTAS.yaml_load(buf) - x = yml['infile'] and return File.open(File.expand_path(x).freeze) + x = yml['infile'] and return File.open(-File.expand_path(x)) end end end @@ -158,9 +158,8 @@ def do_open(path) cur = DTAS.yaml_load(c.req('current')) while @todo_ra > 0 && fp.nil? if current = cur['current'] - track = current['infile'] + track = -current['infile'] break unless track.kind_of?(String) - track.freeze fp = work[track] ||= do_open(track) cur_pid = current['pid'] if fp @@ -197,7 +196,7 @@ def do_open(path) repeat = c.req('tl repeat').split[-1] while @todo_ra > 0 && idx && (cid = ids[idx]) fp = nil - track = c.req("tl get #{cid}").sub!(/\A1 \d+=/, '').freeze + track = -(c.req("tl get #{cid}").sub!(/\A1 \d+=/, '')) begin fp = work[track] ||= do_open(track) rescue SystemCallError diff --git a/lib/dtas/edit_client.rb b/lib/dtas/edit_client.rb index a885060..036d036 100644 --- a/lib/dtas/edit_client.rb +++ b/lib/dtas/edit_client.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 all contributors +# Copyright (C) all contributors # License: GPL-3.0+ # frozen_string_literal: true require 'tempfile' @@ -14,7 +14,7 @@ def editor v.empty? and next return v end - 'vi'.freeze + 'vi' end def client_socket diff --git a/lib/dtas/mcache.rb b/lib/dtas/mcache.rb index 817bfb8..4f1e9e8 100644 --- a/lib/dtas/mcache.rb +++ b/lib/dtas/mcache.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 all contributors +# Copyright (C) all contributors # License: GPL-3.0+ # frozen_string_literal: true # encoding: binary @@ -22,7 +22,7 @@ def lookup(infile) @tbl[bucket] = begin cur = cur ? cur.clear : {} if ret = yield(infile, cur) - ret[:infile] = infile.frozen? ? infile : infile.dup.freeze + ret[:infile] = infile.frozen? ? infile : -(infile.dup) ret[:btime] = DTAS.now end ret diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index ff7440f..243f0b0 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -208,13 +208,13 @@ def client_iter(io, msg) command = msg.shift case command when "enq" - enq_handler(io, msg[0]) + enq_handler(io, -msg[0]) when "enq-cmd" - enq_handler(io, { "command" => msg[0]}) + enq_handler(io, { "command" => -msg[0]}) when "pause", "play", "play_pause" play_pause_handler(io, command) when "pwd" - io.emit(Dir.pwd) + io.emit(-Dir.pwd) else m = "dpc_#{command.tr('-', '_')}" __send__(m, io, msg) if respond_to?(m) diff --git a/lib/dtas/sigevent/fiddle_efd.rb b/lib/dtas/sigevent/fiddle_efd.rb index 40cec77..ec9ec65 100644 --- a/lib/dtas/sigevent/fiddle_efd.rb +++ b/lib/dtas/sigevent/fiddle_efd.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 all contributors +# Copyright (C) all contributors # License: GPL-3.0+ # frozen_string_literal: true @@ -13,7 +13,7 @@ class DTAS::Sigevent # :nodoc: Fiddle::TYPE_INT) # fd attr_reader :to_io - ONE = [ 1 ].pack('Q').freeze + ONE = -([ 1 ].pack('Q')) def initialize fd = EventFD.call(0, 02000000|00004000) # EFD_CLOEXEC|EFD_NONBLOCK diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index e38e23c..6ca29bc 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -63,7 +63,7 @@ def mcache_lookup(infile) comments.each do |k,v| v.chomp! DTAS.try_enc(v, enc) - comments[k] = v + comments[k] = -v end end dst diff --git a/lib/dtas/track.rb b/lib/dtas/track.rb index 85b667a..3f4b813 100644 --- a/lib/dtas/track.rb +++ b/lib/dtas/track.rb @@ -9,6 +9,6 @@ class DTAS::Track # :nodoc: def initialize(track_id, path) @track_id = track_id - @to_path = path + @to_path = -path end end