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

Embedded HTTP benchmark, various small perf improvements #8974

Merged
merged 13 commits into from
Mar 21, 2023

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Mar 20, 2023

This PR contains a benchmark for the full http stack using EmbeddedChannel. It's almost as close to reality as testing TCP directly, but it's on a single thread so it's a bit easier to work with. It stresses the full HTTP stack including netty handlers, routing, filters, serialization and so on.

There are a few minor optimizations with relatively small diffs. There is also one fairly big change: Introducing a new DelayedExecutionFlow which acts kind of like CompletableFuture, but is faster (it doesn't have to support multiple downstreams for every CF).

The changes are separated into individual commits, so you can look at each commit one by one if you want. But they don't cross over each other very much anyway.

I'm not done optimizing, but because the DelayedExecutionFlow is a fairly big diff I want to make this PR before it blows up further.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug B 2 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

80.6% 80.6% Coverage
0.0% 0.0% Duplication

@Requires(property = "spec.name", value = "FullHttpStackBenchmark")
public class SearchController {
@Post("find")
public HttpResponse<?> find(@Body Input input) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to test more variations, like returning a simple string, a completable future reactive response.
Right now the async flow (completable future) is executed using the reactor which can be improved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this benchmark is from micronaut-benchmark, which does not use reactive / async code so that it's a more fair comparison between frameworks. benchmarking reactive code is also worthwhile but this simple controller is basically the best "bare-bones" test of the http stack

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, having some other benchmark testing overhead of async/reactive flow would be nice

* the next step will be executed later
*/
@Nullable
final Step atomicSetOutput(Object output) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to name the methods like they are actually in the flow, setSomethin is very confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean like in the flow? the method sets the output field (if step is unset) which is why it's called that, but yea it does a bit more than set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is just the naming is not very clear to me, I would expect something like process next, but it doesn't matter much

@graemerocher graemerocher merged commit df72e8e into 4.0.x Mar 21, 2023
@graemerocher graemerocher deleted the stack-benchmark branch March 21, 2023 15:50
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.

3 participants