Would you trade 0.1% in performance for a better debugging experience?
Daniel Kozak via Digitalmars-d
digitalmars-d at puremagic.com
Mon Nov 17 23:33:01 PST 2014
Vladimir Panteleev via Digitalmars-d píše v Po 17. 11. 2014 v 23:14
+0000:
> I proposed to build Phobos and Druntime with stack frames enabled:
>
> https://issues.dlang.org/show_bug.cgi?id=13726
>
> Stack frames add three CPU instructions to each function (two in
> the prolog, and one in the epilog). This creates a linked list
> which debuggers, profilers, etc. can easily walk to find which
> function called which. They would allow debugging certain classes
> of bugs much more easily (e.g. the recurring
> InvalidMemoryOperationError - there's a thread about it in
> D.learn just today), and profiling your code with polling
> (non-instrumenting) profilers.
>
> As I understood, in theory, debug information (DWARF and PDB,
> probably not CV) should also contain information allowing an
> accurate stack walk, but it doesn't look like we're currently
> emitting debug information to that level of accuracy. Not all
> debuggers/profilers understand this debug information, either
> (whereas walking the linked list emitted by the stack frames is
> trivial).
>
> We could also start bundling debug builds of Phobos. However,
> these will not help in cases where the performance impact of
> using a full-blown debug build is not acceptable (e.g. if it'll
> skew the profiling results too much, or if you just want readable
> stack frames for your D web service in production).
>
> How much will this cost in performance?
>
> I've run two benchmarks, both show a figure around 0.1%. Many
> performance-sensitive parts of Phobos (std.algorithm) are
> templated and thus are not affected by the Makefile switches. The
> GC is built with -inline, which, although it causes the call
> stack to not contain inlined functions, doesn't cause it to
> abruptly break off like without stack frames.
>
> Is D the first to build its release stdlib with stack frames?
>
> Nope. Microsoft's C release runtime is built stack frames enabled.
>
> Personally, I think the 0.1% is practically negligible
> considering the advantages. My proposal was rejected, so I'd like
> to hear more opinions about this. What do you think?
>
> If you want to run some benchmarks yourself, here are the patches:
>
> https://github.com/CyberShadow/phobos/compare/enable-stack-frames?expand=1
> https://github.com/CyberShadow/druntime/compare/enable-stack-frames?expand=1
>
> Or, using Digger:
>
> digger build
> v2.065.0+CyberShadow/phobos/enable-stack-frames+CyberShadow/druntime/enable-stack-frames
>
> Previous discussion from 2012:
> http://forum.dlang.org/post/zebqmrhcigfuockcpsfa@forum.dlang.org
Short answer: NO.
Long answer:
If I neeed this, I will build version of phobos and druntime myself with
this enabled. Or we could distribute both versions and select one by
some switch. But I am against having stack frames enabled by default.
More information about the Digitalmars-d
mailing list