Shopify / Shopify/app_profiler

Continuous profiling: leverage `rack.after_reply` ?

Open
#135 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
268
Forks
14
Avg merge
1h 9m
Merged PRs (30d)
1

Description

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 ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ProfilingMiddleware and trace how continuous profiling currently generates and extracts StackProf or Vernier data. Investigate the rack.after_reply callback, keeping ad hoc profiling behavior separate. Done means continuous profiles run out of band, include response writing, and avoid adding their processing latency to the user-facing response.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.