Skip to content

Instantly share code, notes, and snippets.

@merrymercy
Last active January 21, 2026 07:21
Show Gist options
  • Select an option

  • Save merrymercy/85b8338ab61ce768ec693cd3ae77c243 to your computer and use it in GitHub Desktop.

Select an option

Save merrymercy/85b8338ab61ce768ec693cd3ae77c243 to your computer and use it in GitHub Desktop.
  1. remove all ad-hoc classes: Remove APIServingTimingMixin, RequestTimingMetricsMixin, TimeStats. Unify to the new API.
    • e.g. many time staus related in ReqState: finished_time
  2. remove ad-hoc code in the critical path. e.g.,
                # Record response sent time right before we send response.
              if not state.response_sent_to_client_ts:
                  state.response_sent_to_client_ts = time.time()
                  out["meta_info"][
                      "response_sent_to_client_ts"
                  ] = state.response_sent_to_client_ts
  1. all api comes from a single base class. ReqTimeStatsBase
  2. The data structure only records a list of monotonically increasing timestamps. People can do analysis (substraction) later.
  3. How to deal with _calculate_timing_metrics. Move to the new dedicated file.

Success metrics:

  1. If we search for time.time() or time.perf_counter(). They only appear in a new file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment