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

Help Request: Perf issue when using puffin #46

Closed
siedentop opened this issue Nov 11, 2021 · 2 comments
Closed

Help Request: Perf issue when using puffin #46

siedentop opened this issue Nov 11, 2021 · 2 comments

Comments

@siedentop
Copy link

Thank you for this awesome project!

I am trying to do some tracing measurements for [binocle][1]. However, when I use tracing with puffin (+puffin_http + viewer), there is a significant slowdown and most scopes do not show.

I prepared a branch which you can run: https://github.com/siedentop/binocle/tree/feature/eframe

cargo run --example create_test_file
cargo run --features trace -- binocle_test_file

Could you please help me and tell me what I might have done wrong?

I know that the Binocle::draw method is using most of the time. (And yes, some work should move to a different thread, but I'd like some measurements first.) However, it only gets called if there is a RedrawRequest event, so it doesn't show in the trace viewer.

With puffin::GlobalProfiler::lock().new_frame(); in the main loop:
Screen Shot 2021-11-10 at 5 08 57 PM

And now with puffin::GlobalProfiler::lock().new_frame(); just inside the if let Event::RedrawRequested(_) = event:

Screen Shot 2021-11-10 at 5 13 38 PM

Any ideas? Many thanks (also feel free to close, if this isn't the right venue).

@emilk
Copy link
Collaborator

emilk commented Nov 11, 2021

If you call puffin::GlobalProfiler::lock().new_frame(); right inside event_loop.run you will be calling it for every new event that is received, which will mean each event will be treated as a new "frame", which is likely not what you want.

Calling it on RedrawRequested seems far more sensible.


As noted in the readme, each puffin profile scope costs 100-200 ns, so creating one for each pixel is a bad idea. Puffin is meant for more coarse-grained profiling.

@siedentop
Copy link
Author

Thank you @emilk! This fixes it.

Originally, I had a trace point inside color_at_index method, which was called for every pixel! But I didn't realize it.

Great framework, and I already found one more performance issue 😊

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

2 participants