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

Play: Optimize usages of route #3842

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Play: Optimize usages of route #3842

merged 2 commits into from
Jun 13, 2024

Conversation

kciesielski
Copy link
Member

@kciesielski kciesielski commented Jun 13, 2024

Closes #3549

Turns out Play calls DefaultPekkoHttpServerComponents.route on each request, so we shouldn't rebuild routing in that method. Instead, it should return a pre-calculated value.
This isn't a fix to Tapir per se, but to all usages of the Play server we have in standard tests and performance tests.
Performance tests used to show terrible latency/throughput and Tapir code occupying over 90% of all frames registered by the profiler.
After this fix, the latency is dramatically better (see the blue line):
image

Throughput also reaches great values: ~160k reqs/sec vs 5k before the fix. Tapir code occupies no more than 9% of all profiler frames. There may be still some possible optimizations in the late 0.999s of latency to reach values closer to the vanilla server under very heavy load, but at this point I don't see them as necessary.

@kciesielski kciesielski marked this pull request as ready for review June 13, 2024 09:11
@kciesielski kciesielski requested a review from adamw June 13, 2024 09:11
@adamw adamw merged commit a8efc67 into master Jun 13, 2024
26 checks passed
@adamw adamw deleted the play-perf-router branch June 13, 2024 10:06
@adamw
Copy link
Member

adamw commented Jun 13, 2024

Nice :)

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

Successfully merging this pull request may close these issues.

Optimize PlayServerInterpreter.toRoutes
2 participants