Dominique Pelle wrote:

> Using the heap memory profiler 'valgrind --tool=massif vim'
> I saw 146,176 bytes allocated from here:
> 
> | | ->02.03% (146,176B) 0x492B61: do_autocmd_event (fileio.c:8623)
> | | | ->02.03% (146,176B) 0x4925F0: do_autocmd (fileio.c:8401)
> | | |   ->02.03% (146,176B) 0x46CFDD: ex_autocmd (ex_docmd.c:5052)
> | | |     ->02.03% (146,176B) 0x46869B: do_one_cmd (ex_docmd.c:2689)
> | | |       ->02.03% (146,176B) 0x465C00: do_cmdline (ex_docmd.c:1127)
> | | |         ->02.01% (145,280B) 0x4638E9: do_source (ex_cmds2.c:3290)
> | | |         | ->02.01% (144,704B) 0x462B65: source_callback 
> (ex_cmds2.c:2717)
> | | |         | | ->02.01% (144,704B) 0x462D66: do_in_runtimepath
> (ex_cmds2.c:2811)
> | | |         | |   ->02.01% (144,704B) 0x462B8F: source_runtime
> (ex_cmds2.c:2731)
> | | |         | |     ->01.82% (131,008B) 0x4769EC: ex_filetype
> (ex_docmd.c:11290)
> ...snip...
> 
> It comes from allocating several 'AutoPat' structures in fileio.c:
> 
> 8623         ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
> 
> Putting some debug printf(), I can see that sizeof(AutoPat)=64 bytes
> (on Linux x86_64). Attached patch reorders fields in AutoPat to
> reduce waste caused by padding & alignment and brings sizeof(AutoPat)
> to 48 bytes.  In this case, it should thus save:
> 
>   146,176 - 146,176/64*48 = 36,544 bytes.
> 
> I'll search for other such optimizations when I have time.

Thanks, I'll add it to the todo list.

Especially when pointers are 64 bit and ints are 32 bit there might be
more places where padding can be removed.

There might also be places where we use several int flags, which could
be replaced by using one int as a bitmask.  That's more work though,
only pays of in structs that are used a lot.

-- 
hundred-and-one symptoms of being an internet addict:
141. You'd rather go to http://www.weather.com/ than look out your window.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui