Skip to content

[DO NOT MERGE] Serve microbenchmark regression investigation - #64934

Closed
jeffreywang88 wants to merge 2 commits into
ray-project:masterfrom
jeffreywang88:revert-freeze-gc-64742
Closed

jeffreywang88 wants to merge 2 commits into
ray-project:masterfrom
jeffreywang88:revert-freeze-gc-64742

Conversation

@jeffreywang88

@jeffreywang88 jeffreywang88 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Confirmation (empirical A/B)

Because #64742's entire runtime effect is gated by RAY_SERVE_FREEZE_GC_ON_STARTUP, toggling that flag on the current build isolates exactly this commit

Ran locally -- single-replica, no-op, 1 node (freeze=0 reproduces pre-#64742 behavior, freeze=1 is current default):

metric freeze=0 freeze=1 Δ
handle throughput (rps) 418.9 474.0 +13.1%
handle_model_comp throughput (rps) 210.7 229.8 +9.1%
handle_100 throughput (rps) 1024.6 1149.9 +12.2%
handle_800 throughput (rps) 922.4 1059.0 +14.8%
handle_10mb p50 latency (ms) 6.15 7.00 +13.8% (worse)
handle_10mb mean latency (ms) 6.99 7.51 +7.4% (worse)

Enabling the freeze reproduces both directions: the no-op throughput jump and the handle_10mb median-latency regression.

What

Revert #64742. Restores the pre-freeze baseline on all serve request-path benchmarks and removes the handle_10mb latency regression.

Notes

  • AI assistance was used to investigate and prepare this revert.

🤖 Generated with Claude Code

jeffreywang88 and others added 2 commits July 22, 2026 12:45
…y-project#64742)"

This reverts commit 1eab59c.

ray-project#64742 made gc.collect()+gc.freeze() run at the end of Replica.initialize,
default-on for every replica. It landed 2026-07-14 and first appeared in the
7/18 serve throughput-optimized nightly microbenchmark, where it caused a
correlated step-change: broad single-replica no-op throughput jumps
(handle / http / grpc / model-comp, every max_ongoing level) AND a handle_10mb
median-latency regression.

Confirmed by an A/B that toggles RAY_SERVE_FREEZE_GC_ON_STARTUP on the current
build (isolating exactly this commit's runtime effect): handle throughput
+12-15% across concurrency, model_comp +9%, and handle_10mb p50 +14% / mean +7%.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Jeffrey Wang <[email protected]>
@jeffreywang88

jeffreywang88 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Handle and HTTP throughput improvement investigation

TL;DR #64742 improves both throughput and latency -> net-positive change.

Throughput-optimized .aws

metric 7/18 master + #64742 revert with #64742
Throughput (rps)
http (mo=5) 3,329.1 2,732.7 +17.9%
http_100 3,324.3 2,659.3 +20.0%
http_800 2,619.6 2,075.7 +20.8%
handle (mo=5) 3,534.9 2,947.5 +16.6%
handle_100 3,595.7 2,954.6 +17.8%
handle_800 3,446.4 2,756.2 +20.0%
grpc (mo=5) 4,518.5 4,464.3 +1.2%
grpc_100 4,511.6 4,493.2 +0.4%
grpc_800 4,582.5 4,527.4 +1.2%
http_model_comp 1,574.9 1,355.8 +13.9%
handle_model_comp 1,024.8 945.0 +7.8%
grpc_model_comp 1,809.5 1,660.7 +8.2%
handle_10mb latency (ms)
handle_10mb p50 24.4 26.4 -8.0%
handle_10mb p90 27.2 31.1 -14.2%
handle_10mb p99 31.2 33.2 -6.5%

Throughput-optimized HAProxy .aws.haproxy (gRPC not run under HAProxy)

metric 7/18 master + #64742 revert with #64742
Throughput (rps)
http (mo=5) 3,295.5 2,794.2 +15.2%
http_100 3,216.0 2,802.1 +12.9%
http_800 2,484.8 2,008.6 +19.2%
handle (mo=5) 3,565.4 2,963.0 +16.9%
handle_100 3,612.8 2,954.9 +18.2%
handle_800 3,495.3 2,786.3 +20.3%
http_model_comp 1,557.1 1,415.8 +9.1%
handle_model_comp 1,028.3 947.4 +7.9%
handle_10mb latency (ms)
handle_10mb p50 24.3 25.2 -3.8%
handle_10mb p90 28.1 29.6 -5.5%
handle_10mb p99 31.0 38.5 -23.9%

@jeffreywang88

jeffreywang88 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@jeffreywang88

Copy link
Copy Markdown
Contributor Author

Handle_10mb latency regression

Branches differ ONLY by #64257 → any delta is attributable to it.

Throughput-optimized

metric pre #101629 post #101630 Δ (post vs pre)
Latency (ms)
handle_10mb p50 11.41 24.48 +114.5%
handle_10mb p90 16.68 29.17 +74.9%
handle_10mb p99 25.39 41.00 +61.5%
handle (small) p50 0.51 0.52 +0.8%
handle_1mb p50 3.06 2.47 −19.5%
http_10mb p50 2.80 2.74 −1.9%
grpc_10mb p50 7.39 7.30 −1.3%
Throughput (rps)
handle 2,976.9 2,996.4 +0.7%
http 2,720.3 2,752.1 +1.2%
grpc 4,639.9 4,486.3 −3.3%
handle_model_comp 964.4 967.4 +0.3%

Throughput-optimized HAProxy

metric pre #101629 post #101630 Δ
handle_10mb p50 20.69 24.89 +20.3%
handle_10mb p90 26.98 29.77 +10.3%
handle_10mb p99 35.07 32.00 −8.7%
handle (small) p50 0.50 0.52 +4.0%
http_10mb p50 2.95 2.99 +1.3%

Non-optimized .aws

metric pre #101629 post #101630 Δ
handle_10mb p50 4.56 5.24 +14.8%
handle_10mb p99 12.41 12.93 +4.2%
handle (small) p50 1.01 1.02 +1.2%
http_10mb p50 4.14 4.31 +4.1%

@jeffreywang88

Copy link
Copy Markdown
Contributor Author

Why #64742 improves both throughput and latency?

A replica holds loaded Python code (functions, classes, module dicts) which contributes most of the GC-tracked objects the cyclic collector has to walk. Freezing skips scanning these frozen immortals — objects that live for the whole process and can never be part of a collectable cycle, so scanning them is pure wasted work.

In turn, each GC scan is cheaper. Since GC runs (stop-the-world) on the event-loop thread, cheaper scans free up CPU that the loop can spend serving requests → higher throughput. And because a collection blocks the loop for its whole duration, when one fires mid-request it directly stalls that in-flight request → freezing shrinks that pause, so latency (especially tail) improves.

[Under investigation] Why #64257 hurts both latency?

It bumped numpy 1→2, pyarrow 19→23, etc. The handle path serializes the 10 MB arg through Ray's object store (numpy/pyarrow stack); a major bump likely lost a zero-copy path, adding a ~1 ms/MB buffer copy (+13 ms at 10 MB). http/grpc bypass that path, so only handle_10mb regresses.

@jeffreywang88

jeffreywang88 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

#64257 upgraded protobuf 4.25.8 → 6.33.6. In throughput-optimized Serve, handle_10mb sends the cloud-pickled 10 MB argument inside a protobuf ASGIRequest over internal gRPC. protobuf 6 makes that large-message gRPC path much slower. Reverting only protobuf restored p50 from ~26 ms to 14–18 ms; reverting numpy/pyarrow or grpcio did not.

The full regression begins at protobuf 5.28:

  • 5.26.1: 17.4 ms
  • 5.27.0: 18.1 ms
  • 5.27.5: 20.9 ms
  • 5.28.3: 26.3 ms
  • 5.29.6 / 6.30 / 6.33: ~26 ms

Note: These numbers may differ from the serve perf dashboards because the serve microbenchmark was run locally on different hardware than the release tests.

@jeffreywang88 jeffreywang88 changed the title Revert "[serve] Freeze GC after replica initialization by default (#64742)" [DO NOT MERGE] Serve microbenchmark regression investigation Aug 4, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 19, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant