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

Buffered reading. #581

Merged
merged 8 commits into from
Jul 2, 2024
Merged

Conversation

thelonelyvulpes
Copy link
Contributor

@thelonelyvulpes thelonelyvulpes commented May 12, 2024

This change introduces a buffered reader between the racing reader and the connection to reduce the number of syscalls required to read messages.

The size of the read buffer is configurable on the driver.

  • Each connection allocates an individual buffer, so memory usage could increase, users should configure this where appropriate, if more syscalls for network reads is seen then increasing the buffer size could help.

Assuming a 16KB Buffer for 100 connections on 3 servers that would equal 16KB * 100 * 3 = ~5MB.
N.b. that 300 connections would indicate a very busy client and 5MB should be considered a relatively small increased footprint.

The default read buffer size is: 32K?

@StephenCathcart
Copy link
Contributor

StephenCathcart commented May 29, 2024

Tests failing due to bufio.Reader not being thread-safe.

Tests fixed

@thelonelyvulpes thelonelyvulpes marked this pull request as ready for review July 1, 2024 07:47
@thelonelyvulpes thelonelyvulpes changed the title [WIP] Buffered io reader. Buffered reading. Jul 1, 2024
* move `DefaultReadBufferSize` to `bolt/connections`
* wrap reader in buffered reader before passing it into the bolt implementations
Avoiding potential race condition where message from previous call could linger
in the channel.
Copy link
Member

@robsdedude robsdedude left a comment

Choose a reason for hiding this comment

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

🧺

@thelonelyvulpes thelonelyvulpes merged commit 14cbf69 into neo4j:5.0 Jul 2, 2024
5 checks passed
@thelonelyvulpes thelonelyvulpes deleted the faster-reading branch July 2, 2024 08:31
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