[cfe-dev] Proposed C++ optimization with big speed gains with big objects

Ladislav Nevery neuralll at gmail.com
Thu Sep 27 09:16:14 PDT 2012


optimization was meant to finally provide effective creation of static
arrays.
Thats why in your case it will simply not be enabled.


TextFile a ("a.txt");
TextFile b ("b.txt");
a = b; //copy the content of b.txt in a.txt

It will be enabled only for usual static array creation to solve horrible
default performance drop with big objects. For example in this specific
example
http://www.codeproject.com/Articles/453022/The-new-Cplusplus-11-rvalue-reference-and-why-you#benchmark_results 
storing 500 big objects to array with useless alloc/copy took 5662ms yet
with copy only for static and move for dynamic object part took 500ms;
with such swich even static copy will be removed.

Assign to large static array are simple to isolate and sheer number of
elements brings big performance gain when fixed.

That's why I focus and enable it only only on first static array reference
assign(where element is after default constructor without side effects(not
referencing calls other than memset/malloc))


TextFile textfile[1000]

textfile[1]=TextFile("a.txt"); // = we call destructor doing nothing
and placement new
textfile[1]=TextFile("b.txt"); // standard temp copy + operator combo

a = b; //copy the content of b.txt in a.txt



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Proposed-C-optimization-with-big-speed-gains-with-big-objects-tp4026886p4026990.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list