Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy backtrace #30

Closed
Yamakaky opened this issue Feb 17, 2017 · 8 comments
Closed

Lazy backtrace #30

Yamakaky opened this issue Feb 17, 2017 · 8 comments

Comments

@Yamakaky
Copy link

Do you think it would be feasible to add some kind of LazyBacktrace? Instead of calling trace then resolve, it would only call trace, then have a fn resolve() -> Backtrace. Alternatively, it could be an enum with Backtrace and Vec<Frame::ip> as variants.

I came on this idea by thinking about rust-lang-deprecated/error-chain#129 (comment).

@alexcrichton
Copy link
Member

Seems plausible!

@Yamakaky
Copy link
Author

Well, Frame is not clone, so we can't simply get it out of trace(). Do you think it could be Clone?

@alexcrichton
Copy link
Member

Seems fine

@Yamakaky
Copy link
Author

Yeah, it may be worth to add it. With https://play.rust-lang.org/?gist=6557542b1c00bce1c6528b7daccee877&version=stable&backtrace=1, c() is three times faster that b().

@golddranks
Copy link

rust-lang-deprecated/error-chain#129 (comment) If @mitsuhiko is right that CoreSymbolication is especially slow at the rendering phase (and I am understanding correctly that "Lazy" here means that it collects the required info but lazily resolves it when the actual backtrace is needed...), this could lead to tremendous speedups on Mac.

@Yamakaky
Copy link
Author

#32

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

I was just hit by this -- Backtrace::new takes multiple seconds the first time it is run, and later it is still extremely expensive. I was wondering why the program suddenly ran so slow, and the reason ended up being Err values that were created and then caught again, but already had their backtrace resolved.

I had to resort to rust-lang/miri#283 to fix this. Unfortunately, this means we have to use the low-level APIs (trace and resolve), which are not particularly pleasant to work with. (Getting an iterator rather than having to specify a closure would make this much nicer ;)

@alexcrichton
Copy link
Member

Getting an iterator rather than having to specify a closure would make this much nicer

Agreed! This is unfortunately, however, not possible due to how some platform apis are implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants