From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14059 invoked by alias); 11 Jun 2016 07:41:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21647 Received: (qmail 23738 invoked from network); 11 Jun 2016 07:41:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7Fh0vzNPaPnvbK+/aj4JDVgTmQHwAeiJKyVw9BMVDBY=; b=wX8sITBp+tLzxf2TIC2A7JbLabUwOvkuyCf5+h8jnQ/c11g5O4Twrf02B7zu9myoAV FYC+oAQvnOoNLPfaSJskKwDS1rNaIod8mshVphP7tr6LB36T9RlT/iCAMLQiEmG2q/AP Wz26XVhOJaHdF368fRhFo5tMUOZTAvOxgyRdh6GeaE3VEoBpaaXR2UBO9BcfXsLACoxa qnCe8R9/CFGT+b6p47zZD/jmvDRL8bzmg6gqWZBCH/i34QnBdPwJgGL9Bx+hxlfee1zu ClYS9xsTWqLETHMZV7YJGT9B4x6WotnyDROjxbs3E7GrcGGYV3VRZv2w6wBBp4u0YE7M ueeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7Fh0vzNPaPnvbK+/aj4JDVgTmQHwAeiJKyVw9BMVDBY=; b=GVu6EBif6Rpext8vu3DZdCoNSbA4vA8btP5aIUv44TRRTCkkeLwefESWv3/JV90H8d DGTBN4WWYrUK48IsAfZJ6WtNXwfLwibqMEUVl3JnB5WfVmXvblO3j9LU4xZaglrGQEaG X5wYqn3reJi42p88Te9OJKkbowU4B070g1ggMdZkDujZZpWfTbQVDNwuzd0wzry5x3QI A8UM3HjEHZ5SWQSxSZPHlkaMuM3EDi4N6rnxsKlIKqx81tXONIbM7Pa3KuUEE15TcAow H7usnt2anjIVjRoR8i2S/U6863kdhA/gU5EFcBBEFGc3KadgpFxhHXxsje5kAJhKMnv0 rQOA== X-Gm-Message-State: ALyK8tIpCuIZMJ94WA+1UrVrYtXX9cmBHw7t44nnW+FYUyFz1Z7dfUubRklEzPBEUVpaUxPijhgDd4oZYb55HQ== X-Received: by 10.140.136.16 with SMTP id 16mr5707079qhi.25.1465630865829; Sat, 11 Jun 2016 00:41:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <160610203056.ZM10515@torch.brasslantern.com> References: <160508093530.ZM9686@torch.brasslantern.com> <160610203056.ZM10515@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Sat, 11 Jun 2016 09:40:46 +0200 Message-ID: Subject: Re: One more heap optimization trick for zsh < 5.2 To: Bart Schaefer Cc: Zsh Users Content-Type: multipart/mixed; boundary=001a1138ee4e2272850534fbc703 --001a1138ee4e2272850534fbc703 Content-Type: text/plain; charset=UTF-8 On 11 June 2016 at 05:30, Bart Schaefer wrote: > This means that it has to be something that's happening in the loop > inside the n-list function, affecting every iteration. Agree > Consequently it must be one of n-list-input or n-list-draw, both of > which are declared with [the shadowed] autoload inside n-list itself. > Something about nesting calls to --zplg-reload-and-run is causing > the issue. Hmm didn't thought about that, about nesting > It might have something to do with retaining the old copy > of the function body until the call stack unwinds and it can safely > be freed; a large value for $argv would therefore also hang around > (two copies of it) for all of that time. That's apparently a hit. I attach two test files. First doesn't pass anything to sub-function: # ./aload.zsh2.txt Normal autoload: ( aload_fun_main; ) 10,91s user 0,23s system 99% cpu 11,156 total Special autoload: ( aload_fun_main; ) 9,54s user 0,23s system 99% cpu 9,792 total More special autoload: ( aload_fun_main; ) 9,15s user 0,22s system 99% cpu 9,393 total # ./aload.zsh2.txt Normal autoload: ( aload_fun_main; ) 8,85s user 0,22s system 99% cpu 9,103 total Special autoload: ( aload_fun_main; ) 8,15s user 0,23s system 99% cpu 8,405 total More special autoload: ( aload_fun_main; ) 9,36s user 0,22s system 99% cpu 9,596 total # ./aload.zsh2.txt Normal autoload: ( aload_fun_main; ) 10,22s user 0,22s system 99% cpu 10,454 total Special autoload: ( aload_fun_main; ) 9,73s user 0,22s system 99% cpu 9,971 total More special autoload: ( aload_fun_main; ) 8,02s user 0,22s system 99% cpu 8,262 total (I wonder why the varying). Second one passes long array to sub-function: # ./aload.zsh3.txt Normal autoload: ( aload_fun_main; ) 11,58s user 0,25s system 99% cpu 11,847 total Special autoload: ( aload_fun_main; ) 10,77s user 0,25s system 99% cpu 11,042 total More special autoload: ( aload_fun_main; ) 18,38s user 0,27s system 99% cpu 18,679 total # ./aload.zsh3.txt Normal autoload: ( aload_fun_main; ) 10,99s user 0,25s system 99% cpu 11,270 total Special autoload: ( aload_fun_main; ) 10,71s user 0,26s system 99% cpu 10,984 total More special autoload: ( aload_fun_main; ) 19,02s user 0,28s system 99% cpu 19,329 total > Incidentally, the way n-list is currently written, it will re-autoload > those functions and re-create all the _nlist_* helpers EVERY TIME IT > IS RUN. Mostly that's all of no net effect, but it must be slowing > down each call to n-list at least a little bit. I have a check if the function exists and don't do autoload, like the real autoload function does afaik. -- Best regards, Sebastian Gniazdowski --001a1138ee4e2272850534fbc703 Content-Type: text/plain; charset=US-ASCII; name="aload.zsh3.txt" Content-Disposition: attachment; filename="aload.zsh3.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ipaur4p10 IyEvYmluL3pzaAoKZW11bGF0ZSAtTFIgenNoCgotLXJlbG9hZC1hbmQtcnVuICgpIHsKICAgIGxv Y2FsIGZwYXRoX3ByZWZpeD0iJDEiIGF1dG9sb2FkX29wdHM9IiQyIiBmdW5jPSIkMyIKICAgIHNo aWZ0IDMKICAgIHVuZnVuY3Rp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9sb2FkOiIKdGltZSAoIGFsb2FkX2Z1bl9tYWluICkKdW5mdW5j dGlvbiBhbG9hZF9mdW5fbWFpbgp1bmZ1bmN0aW9uIGFsb2FkX2Z1bgoKIyBNb3JlIHNwZWNpYWwg YXV0b2xvYWQKUExVR0lOX0RJUj1gcHdkYApldmFsICIKZnVuY3Rpb24gYWxvYWRfZnVuX21haW4g ewogICAgLS1yZWxvYWQtYW5kLXJ1biAkeyhxKVBMVUdJTl9ESVJ9ICcnIGFsb2FkX2Z1bl9tYWlu Cn0KIgpldmFsICIKZnVuY3Rpb24gYWxvYWRfZnVuIHsKICAgIC0tcmVsb2FkLWFuZC1ydW4gJHso cSlQTFVHSU5fRElSfSAnJyBhbG9hZF9mdW4KfQoiCmVjaG8gIk1vcmUgc3BlY2lhbCBhdXRvbG9h ZDoiCnRpbWUgKCBhbG9hZF9mdW5fbWFpbiApCnVuZnVuY3Rpb24gYWxvYWRfZnVuX21haW4KdW5m dW5jdGlvbiBhbG9hZF9mdW4KCg== --001a1138ee4e2272850534fbc703 Content-Type: text/plain; charset=US-ASCII; name="aload.zsh2.txt" Content-Disposition: attachment; filename="aload.zsh2.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ipaur4pp1 IyEvYmluL3pzaAoKZW11bGF0ZSAtTFIgenNoCgotLXJlbG9hZC1hbmQtcnVuICgpIHsKICAgIGxv Y2FsIGZwYXRoX3ByZWZpeD0iJDEiIGF1dG9sb2FkX29wdHM9IiQyIiBmdW5jPSIkMyIKICAgIHNo aWZ0IDMKICAgIHVuZnVuY3Rpb24gIiRmdW5jIgogICAgbG9jYWwgRlBBVEg9IiRmcGF0aF9wcmVm aXgiOiIke0ZQQVRIfSIKICAgIGJ1aWx0aW4gYXV0b2xvYWQgJD1hdXRvbG9hZF9vcHRzICIkZnVu YyIKICAgICIkZnVuYyIgIiRAIgp9CgpmYm9keTE9JyMhL2Jpbi96c2gKc3RyPSIiCnN0cj0keyhy OjEwMDAwMDo6Xzopc3Ryf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