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

Continuous profiling: leverage rack.after_reply ? #135

Open
casperisfine opened this issue Sep 6, 2024 · 2 comments
Open

Continuous profiling: leverage rack.after_reply ? #135

casperisfine opened this issue Sep 6, 2024 · 2 comments

Comments

@casperisfine
Copy link
Contributor

One thing I noticed when investigating something with request profiling is that the actual request response time is always a few hundred ms longer than the stackprof or vernier resulting profile.

While both are relatively low overhead when active, I think generating and extracting the profiling data takes a while and impact user experience.

When doing continuous profiling, instead of doing all that from ProfilingMiddleware, we could register a rack.after_reply callback so it's done out of band. Of course of ad hoc profiling, we can't do that because we need to change the response etc.

The advantages are multiple:

  • Less impact on the user experience (less latency impact)
  • The profile would also include writing the response to the client, so if there is performance to be gained in this part of the server, we'd see it.

cc @dalehamel @bmansoob thoughts ?

@bmansoob
Copy link
Contributor

bmansoob commented Sep 6, 2024

For continuous profiling, it is always done async in a background thread. So at least the biggest cost (external call to GCS) happens out of band.

The profile would also include writing the response to the client,

this is an interesting point.

@casperisfine
Copy link
Contributor Author

Oh I see. I guess my case wasn't exactly continuous profiling. I was adding logic to the profiling middleware to then call super with a specific Parameter object, hence why I had user impact.

So yeah, I suppose it's not that important.

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