Skip to content

Improve#45

Merged
dinosaure merged 2 commits intomainfrom
improve
Feb 28, 2026
Merged

Improve#45
dinosaure merged 2 commits intomainfrom
improve

Conversation

@dinosaure
Copy link
Contributor

We just pre-allocated buffers to read/write and we improve a bit the code. We are also be able to catch-up earlier when the user wants to stop the server.

@hannesm
Copy link

hannesm commented Feb 27, 2026

I've a hard time figuring out the allocation behaviour before and after, so now we preallocate? how big are the buffers being allocated? are those for each connection read and write direction?

@dinosaure
Copy link
Contributor Author

We can split the improvement into 3 parts:

  1. the buffer size, here we enlarge the buffer from 2047 bytes to 16383 bytes, you can see the diff here.
  2. we pre-allocate a read buffer and a write buffer to copy between bigarray and bytes, you can see the diff here.
  3. and we set the socket with TCP_NODELAY, you can see the diff here

From my experiment, it's a win but I'm currently try to provide a reproducible benchmark between httpcats, vif and httpun+eio.

@dinosaure
Copy link
Contributor Author

I just need to keep in my mind that the second point (use the same buffer with Bytes.unsafe_to_string. see here does not work (probably) for mhttp (but we can figure out about an extra allocation with the underlying layer Flow).

@dinosaure dinosaure merged commit 7f23857 into main Feb 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants