From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: Slowdown around 5.0.5-dev-0
Date: Sun, 11 Oct 2015 10:39:16 +0200 [thread overview]
Message-ID: <CAKc7PVD8dU29eyfF-QJPUicFGUT6Kpomu+qZNungwnXpbjCH7Q@mail.gmail.com> (raw)
In-Reply-To: <151010232045.ZM12931@torch.brasslantern.com>
[-- Attachment #1: Type: text/plain, Size: 3248 bytes --]
Zprof says there is no change:
https://youtu.be/6A-AKesvZKM
I also attach zprof result in file. BTW, the patch didn't apply to
head or to 23f98c3, I had to make changes manually.
Best regards,
Sebastian Gniazdowski
On 11 October 2015 at 08:20, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Oct 10, 5:06pm, Bart Schaefer wrote:
> }
> } This suggests a couple of possible fixes, but I've run out of time to
> } experiment right now.
>
> OK, this is the least intrusive change I can think of that might make
> a difference. What this attempts to do is maintain a second pointer
> into the list of heaps that tells freeheap() where to start working.
> It's set on pushheap() and reset on popheap() so it freeheap() should
> avoid searching for free space in some arenas that were completely
> filled before pushheap() was called. However, it won't improve the
> performance if there are a whole lot of heap arenas each with a small
> amount of space available at the time of pushheap().
>
> To improve THAT situation, I think we'd have to be willing to "leak"
> those small pieces of heap until a popheap() happens, and instead
> use at least one new arena following most calls to pushheap(). This
> might mean that zsh's memory footprint grows, but on modern hardware
> that may not be an issue.
>
> All tests pass with this change in place, let's see what it does with
> Sebastian's 89k array elements.
>
>
> diff --git a/Src/mem.c b/Src/mem.c
> index b9569ea..01072a3 100644
> --- a/Src/mem.c
> +++ b/Src/mem.c
> @@ -127,6 +127,12 @@ static Heap heaps;
>
> static Heap fheap;
>
> +/* same as fheap, except in the preceding stack context (it will be the
> + * first heap from which space in the current context may be recovered
> + * when heap space is freed) */
> +
> +static Heap fpop;
> +
> /**/
> #ifdef ZSH_HEAP_DEBUG
> /*
> @@ -293,8 +299,11 @@ pushheap(void)
> h_push++;
> #endif
>
> + fpop = NULL;
> for (h = heaps; h; h = h->next) {
> DPUTS(!h->used, "BUG: empty heap");
> + if (!fpop && h->used < ARENA_SIZEOF(h))
> + fpop = h;
> hs = (Heapstack) zalloc(sizeof(*hs));
> hs->next = h->sp;
> h->sp = hs;
> @@ -341,9 +350,10 @@ freeheap(void)
> *
> * However, if the arena to which fheap points is unused, we want to
> * free it, so we have no choice but to do the sweep for a new fheap.
> + * fpop is the first heap with free space following pushheap().
> */
> if (fheap && !fheap->sp)
> - fheap = NULL; /* We used to do this unconditionally */
> + fheap = fpop;
> /*
> * In other cases, either fheap is already correct, or it has never
> * been set and this loop will do it, or it'll be reset from scratch
> @@ -417,7 +427,7 @@ popheap(void)
> h_pop++;
> #endif
>
> - fheap = NULL;
> + fheap = fpop = NULL;
> for (h = heaps; h; h = hn) {
> hn = h->next;
> if ((hs = h->sp)) {
> @@ -443,6 +453,8 @@ popheap(void)
> #endif
> if (!fheap && h->used < ARENA_SIZEOF(h))
> fheap = h;
> + if (!fpop && h->sp && h->sp->used < ARENA_SIZEOF(h))
> + fpop = h;
> zfree(hs, sizeof(*hs));
>
> hl = h;
[-- Attachment #2: result.txt --]
[-- Type: text/plain, Size: 1956 bytes --]
patched:
# time ( npanelize < ~/lsoflsof )
num calls time self name
-----------------------------------------------------------------------------------
1) 161 5453,04 33,87 43,53% 5453,04 33,87 43,53% _nlist_print_with_ansi
2) 1 12500,28 12500,28 99,79% 4052,65 4052,65 32,35% n-list
3) 7 8041,91 1148,84 64,20% 2588,87 369,84 20,67% n-list-draw
4) 7 327,91 46,84 2,62% 322,30 46,04 2,57% n-list-input
5) 7 40,77 5,82 0,33% 31,97 4,57 0,26% _nlist_setup_user_vars
6) 7 28,91 4,13 0,23% 28,91 4,13 0,23% _nlist_status_msg
7) 2 24,94 12,47 0,20% 24,94 12,47 0,20% _nlist_cursor_visibility
8) 1 26,79 26,79 0,21% 9,97 9,97 0,08% _nlist_exit
( n-panelize < ~/lsoflsof; ) 14,33s user 0,27s system 94% cpu 15,488 total
clean:
# time ( npanelize < ~/lsoflsof )
num calls time self name
-----------------------------------------------------------------------------------
1) 161 5410,49 33,61 43,57% 5410,49 33,61 43,57% _nlist_print_with_ansi
2) 1 12391,49 12391,49 99,78% 4030,62 4030,62 32,46% n-list
3) 7 7961,76 1137,39 64,11% 2551,27 364,47 20,54% n-list-draw
4) 7 324,36 46,34 2,61% 318,36 45,48 2,56% n-list-input
5) 7 39,22 5,60 0,32% 31,44 4,49 0,25% _nlist_setup_user_vars
6) 7 27,86 3,98 0,22% 27,86 3,98 0,22% _nlist_status_msg
7) 2 24,35 12,18 0,20% 24,35 12,18 0,20% _nlist_cursor_visibility
8) 1 27,05 27,05 0,22% 10,37 10,37 0,08% _nlist_exit
( n-panelize < ~/lsoflsof; ) 14,19s user 0,29s system 94% cpu 15,319 total
next prev parent reply other threads:[~2015-10-11 8:39 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 10:54 Sebastian Gniazdowski
2015-10-10 17:58 ` Bart Schaefer
2015-10-10 18:11 ` Sebastian Gniazdowski
2015-10-10 18:32 ` Sebastian Gniazdowski
2015-10-11 0:06 ` Bart Schaefer
2015-10-11 6:20 ` Bart Schaefer
2015-10-11 8:39 ` Sebastian Gniazdowski [this message]
2015-10-11 16:17 ` Bart Schaefer
2015-10-11 16:48 ` Sebastian Gniazdowski
2015-10-11 17:31 ` Bart Schaefer
2015-10-11 18:05 ` Sebastian Gniazdowski
2015-10-11 21:22 ` Bart Schaefer
2015-10-12 8:21 ` Sebastian Gniazdowski
2015-10-12 14:01 ` Bart Schaefer
2015-10-12 16:50 ` Sebastian Gniazdowski
2015-10-13 0:33 ` Bart Schaefer
2015-10-13 8:21 ` Sebastian Gniazdowski
2015-10-13 15:52 ` Bart Schaefer
2015-10-14 6:50 ` Sebastian Gniazdowski
2015-10-14 13:27 ` Peter Stephenson
2015-10-14 16:25 ` Bart Schaefer
2015-10-14 16:50 ` Bart Schaefer
2015-10-15 4:32 ` Bart Schaefer
2015-10-15 13:03 ` Sebastian Gniazdowski
2015-10-16 0:35 ` Bart Schaefer
2015-10-17 9:12 ` Sebastian Gniazdowski
2015-10-17 9:24 ` Sebastian Gniazdowski
2015-10-18 16:19 ` Bart Schaefer
2015-10-18 20:40 ` Sebastian Gniazdowski
2015-10-18 21:07 ` Bart Schaefer
2015-10-18 21:31 ` Sebastian Gniazdowski
2015-10-19 17:21 ` Bart Schaefer
2015-10-22 12:49 ` Sebastian Gniazdowski
2015-10-22 15:00 ` Bart Schaefer
2015-10-22 16:28 ` Sebastian Gniazdowski
2015-10-22 16:33 ` Sebastian Gniazdowski
2015-10-23 15:40 ` Sebastian Gniazdowski
2015-10-23 15:57 ` Sebastian Gniazdowski
2015-10-23 19:26 ` Bart Schaefer
2015-10-23 23:50 ` Bart Schaefer
2015-10-24 6:09 ` Sebastian Gniazdowski
2015-10-24 7:37 ` Sebastian Gniazdowski
2015-10-24 8:04 ` Sebastian Gniazdowski
2015-10-24 19:39 ` Bart Schaefer
2015-10-25 7:35 ` Sebastian Gniazdowski
2015-10-25 17:23 ` Bart Schaefer
2015-10-25 20:56 ` Sebastian Gniazdowski
2015-10-26 0:49 ` Bart Schaefer
2015-10-26 7:41 ` Sebastian Gniazdowski
2015-10-26 7:47 ` Sebastian Gniazdowski
2015-10-24 6:27 ` Sebastian Gniazdowski
2015-10-24 10:54 ` Sebastian Gniazdowski
2015-10-24 11:25 ` Sebastian Gniazdowski
2015-10-24 16:31 ` Bart Schaefer
2015-10-24 16:41 ` Bart Schaefer
2015-10-23 6:32 ` Sebastian Gniazdowski
2015-10-16 0:37 ` Bart Schaefer
2015-10-13 13:07 ` Sebastian Gniazdowski
2015-10-13 13:31 ` Sebastian Gniazdowski
2015-10-12 12:05 ` Sebastian Gniazdowski
2015-10-12 15:13 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKc7PVD8dU29eyfF-QJPUicFGUT6Kpomu+qZNungwnXpbjCH7Q@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).