Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Optimizations, extra memory of (r) flag (the padding)



On 9 April 2017 at 09:00:00, Sebastian Gniazdowski (psprint@xxxxxxxxxxx) wrote:
> without test-zsh running). So I dropped the test, because saturating 270 MB with array  
> append without optimizations could take more than a day. That said, why the extra memory  
> on current HEAD?

I bisected this to:

9f8e3e8    36834: freeheap preserves last allocated heap

It was an important optimization that made Zsh fast under heavy memory loads. To see the double-memory usage:

% a=${(r:1024*1024*100::_:)x}
% mem() { ps -axv | grep $$ }
% mem
21525 S      0:06.20   0   0      0  2681728 222308     -        0   1,3  2,7 /usr/local/bin/zsh-5.3.1-dev-0 -i

RSS is 8th column. So, instead of 100 MB, there's 200 MB. However, to show that this is heap memory hanging around:

% repeat 1; do a=${(r:1024*1024*100::_:)x}; done
% mem
21772 S      0:05.84   0   0      0  2579324 119932     -        0   2,7  1,4 /usr/local/bin/zsh-5.3.1-dev-0 -i

Now things are in check – 100 MB (119932) in `ps`. I think this isn't a big problem, that heap memory can hang around longer, if it boosts Zsh speed under high memory loads.

--
Sebastian Gniazdowski
psprint /at/ zdharma.org



Messages sorted by: Reverse Date, Date, Thread, Author