bcraig added a comment. In http://reviews.llvm.org/D20933#447608, @zaks.anna wrote:
> Does FoldingSet already have reserve? (I do not see it.) The reserve call would be new. I'm attempting to add it in this llvm review: http://reviews.llvm.org/D20930 > My understanding is that you propose to allocate all the nodes that would be > required to store the maximum number of nodes we allow, lowering the malloc > traffic. The current implementation just doubles the size. Is this correct? > > Maybe we should just set a higher initial size, instead of going all the way > to the max? The implementation of FoldingSet has a vector of bucket pointers. Reserve preallocates that vector of bucket pointers to the correct size to avoid rehashing. The allocation of the nodes themselves hasn't changed. With a value of 150,000 steps (the default?), reserve will preallocate 131072 bucket pointers (this gives a node capacity of double that). On a 64-bit system, that's a 1 MB allocation. Note that the biggest savings are in avoiding the last rehashing. If we shrink the initial size, but still rehash frequently, we'll lose a lot of the benefits. http://reviews.llvm.org/D20933 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits