-
Notifications
You must be signed in to change notification settings - Fork 798
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
Wrap PrintWriter with BufferedWriter #540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've failing CI tests.
context.setContextPath("/"); | ||
context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics"); | ||
|
||
Server server = new Server(1234); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to run a HTTP server to test this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hasn't been addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required since bottleneck is container-specific. For example, with Jetty 8.1.7 the bottleneck seems to be the ByteArrayBuffer instances. But with Jetty 9.4.27, ByteArrayBuffer is no longer an issue but another part of the code is consuming CPU cycles. In either case, the wrapper patch improved the performance by approximately the same amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we at least bind to 0 so we don't clash with any existing listeners?
Signed-off-by: Takanori Takase <[email protected]>
Signed-off-by: Takanori Takase <[email protected]>
Signed-off-by: Takanori Takase <[email protected]>
52c3624
to
87918da
Compare
Signed-off-by: Takanori Takase <[email protected]>
Thanks! |
Thanks for the review & merge :) |
Hi @brian-brazil,
Generating servlet output for a large number of metrics seems to be inefficient, since the underlying
PrintWriter
implementation is generating too manyorg.eclipse.jetty.io.ByteArrayBuffer
instances.Performance improved by simply wrapping the
PrintWriter
withBufferedWriter
. Microbenchmark (ExampleBenchmark
, 10k gauges, 100 iterations, laptop machine) shows that it takes around 2.5 sec with the wrapper, and around 5.5 sec without the wrapper.