[llvm-commits] [cfe-commits] [PATCH][Review Request] EarlyCSE stack overflow - bugzilla 11794

Andrew Trick atrick at apple.com
Fri Jan 20 11:21:15 PST 2012

On Jan 19, 2012, at 3:41 PM, Jakob Stoklund Olesen wrote:

> On Jan 19, 2012, at 1:41 PM, Lenny Maiorani wrote:
>> Before I blindly stated that I thought std::stack or std::deque would be better, I decided I would verify this.
> Yay for SCIENCE!


>> I wrote a small test of a few different implementation (std::list, std::stack, std::deque, std::vector, and std::deque using iterator-insert) attempting to perform the same operations as the necessary ones in EarlyCSE.cpp. It is distilled down to just the performance of the actual data structures under the assumed conditions. Attached (stack-test.cpp).
>> As it turns out, the "best" implementation in terms of performance is std::deque using the "iterator-insert", by a wide margin. On my lowly laptop, after compiling the test with 'clang++ -O2', I get the following results:
>> List: 92.473490 seconds
>> Stack: 15.575143 seconds
>> Deque: 9.129154 seconds
>> Deque iter insert: 7.384741 seconds
>> Vector: 13.387473 seconds

My stack (doing the same thing as deque iter insert):
accum = -12238
time = 63.691762 seconds

Deque iter insert:
accum = -12238
time = 67.037268 seconds

accum = -12238
time = 84.097848 seconds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stack-test.cpp
Type: application/octet-stream
Size: 6850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120120/2a6e2884/attachment.obj>
-------------- next part --------------

Yay for simplicity and common sense. I don't think you need a benchmark to prove that one data structure access is faster than two of the same type of access.

> Thanks for taking the time to do this and actually posting numbers.

Thanks Lenny. I'd like to see more measurements in general. I just want to give Jakob a hard time for his faith in numbers.


More information about the llvm-commits mailing list