-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reduce allocations & test we don't regress (#316)
Motivation: The ping/pong test should only do 4 allocations: - readFromSocket does unconditionally allocate one ByteBuffer (allocating one ByteBuffer does 2 allocations) - we have a ping and a pong side, each call readFromSocket so 2 * 2 = 4 allocations per message. Before adding the `@_inlineable` to the read/write/get/set integer methods in ByteBuffer however I was seeing way more allocations. So looked at them and fixed them. Turns out that massively reduces the number of allocations for HTTP too. On Linux I was seeing this change: 1000_reqs_1_conn: 282000 -> 70000 1_reqs_1000_conn: 1287000 -> 907000 Modifications: - made the ByteBuffer integer methods inlineable - added a test that makes sure we don't regress on the simplest possible use of NIO: a ping/pong server Result: After your change, what will change.
- Loading branch information
Showing
3 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters