Bug 10864 – [REG 2.064][PERFORMANCE] new Safe appender is slower than "~="
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-21T03:19:00Z
Last change time
2013-11-28T09:22:24Z
Keywords
performance
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2013-08-21T03:19:47Z
The new Appender is now @safe and pure. This was done mostly by https://github.com/D-Programming-Language/phobos/pull/1337 , which is done with heavy usage of the trusted lambda idiom, eg:
() @trusted {unsafe code here;} ();
The problem is that doing this has a very high runtime cost.
Currently, my benches get improved performance by *not* using appender.
This can be fixed either by using the same "named" idiom:
void do_it() @trusted {unsafe code here;}
do_it();
(for reasons I do not understand, *that* has no extra runtime cost, even in non-optimized/non-inline mode).
Or by fixing:
http://d.puremagic.com/issues/show_bug.cgi?id=10848
Appender being one of the "foundation" blocks of most of phobos, this is arguably a permance-blocker.
Comment #1 by verylonglogin.reg — 2013-09-29T14:39:04Z
We can create a single @trusted `impl*` function and then call it from main one. Then e.g. make a fake call to stuff wich defines @safe-ness to get right attributes.
Comment #2 by monarchdodra — 2013-11-28T09:22:24Z
Can't remember which pull exactly fixes it, but it is fixed now.