<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 15, 2013 at 12:31 PM, Stephen Checkoway <span dir="ltr"><<a href="mailto:s@pahtak.org" target="_blank" class="cremed">s@pahtak.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Oct 15, 2013, at 2:43 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" class="cremed">chandlerc@google.com</a>> wrote:<br>
<br>
> Have you looked into the LLVM ilist? Its intrusive and so should be a touch faster and a touch more memory dense than std::list.<br>
<br>
</div>I hadn't looked at it before. This would require adding next and prev pointers to MCDecodedInst? Unless I'm missing something, wouldn't this result in exactly the same memory usage.<br>
<br>
list<MCDecodedInst> has nodes of type _List_node<MCDecodedInst> which is a subclass of __detail::_List_node_base so it should have three members:<br>
_List_node_base *_M_next<br>
_List_node_base *_M_prev<br>
MCDecodedInst _M_data<br>
(at least using libstdc++).<br>
<br>
That should have the same memory usage, no?<br>
<br>
As a sanity check,<br>
<br>
#include <llvm/MC/MCAtom.h><br>
#include <cstdio><br>
#include <list><br>
<br>
int main()<br>
{<br>
  printf("%zu\n", alignof(llvm::MCDecodedInst));<br>
  printf("%zu\n", sizeof(llvm::MCDecodedInst));<br>
  printf("%zu\n", sizeof(typename std::list<llvm::MCDecodedInst>::_Node));<br>
  return 0;<br>
}<br>
<br>
prints 8, 184, 200 for 64-bit and 4, 132, 140 for 64-bit.<br>
<br>
Where do you see memory improvements?<br></blockquote><div><br></div><div>Typically, fragmentation and alignment. It seems we're lucky with the alignment though.</div><div><br></div><div>Maybe it doesn't matter for your use case. Many of LLVM's types use ilist and have benefitted from it, so I at least wanted to see if you had checked.</div>
</div></div></div>