
On Wed, Dec 14, 2016 at 11:46 PM, Niall Douglas
On 15 Dec 2016 at 15:01, Gavin Lambert wrote:
I've not taken a look at the proposed Stacktrace library, but from what I know obtaining a stacktrace is typically a rather expensive operation. I expect it to be no less expensive than throwing the exception. That's probably too much to pay for by default. Plus, it adds one more dependency on another library via such a core component as BOOST_THROW_EXCEPTION.
For a capture depth of seven frames, it costs about 30 microseconds on Microsoft Windows. Stack backtracing is inherently cache unfriendly. That is a lot more than throwing an exception.
The people on SG14 have tried quite hard to demonstrate that throwing exceptions is slower than alternatives, but it has proven surprisingly hard to conclusively prove it in real world code. I am sure the compiler vendors would say "I told you so ..."
+1.
Capturing the stack to later perform a trace is relatively cheap and fast (though perhaps memory wasteful, though you usually wouldn't care about that unless the exception was due to running out of memory). It's interpreting that data into a human-readable trace that's the slow part.
Multiple orders of magnitude difference yes.
+1 With regards to integration into boost::throw_exception, obviously we only need to capture the data not format it. Emil