Add initial prototype of http over libp2p#2218
Closed
Conversation
Contributor
marten-seemann
left a comment
There was a problem hiding this comment.
LGTM, except for the content length issue. Maybe creating a net.Listener isn't that bad after all, at least we wouldn't have to deal that much with HTTP internals.
Comment on lines
+14
to
+24
| var bufWriterPool = sync.Pool{ | ||
| New: func() any { | ||
| return bufio.NewWriterSize(nil, 4<<10) | ||
| }, | ||
| } | ||
|
|
||
| var bufReaderPool = sync.Pool{ | ||
| New: func() any { | ||
| return bufio.NewReaderSize(nil, 4<<10) | ||
| }, | ||
| } |
Contributor
There was a problem hiding this comment.
Probably doesn't matter (and definitely not for a prototype): What about creating a new reader / writer, but taking the underlying the byte slice from our shared buffer pool? That's an additional alloc for the bufio.{Reader/Writer}, but we get better byte slice reuse.
Collaborator
Author
There was a problem hiding this comment.
We get to reuse the whole thing here which is probably net better for the GC.
This was referenced Mar 26, 2023
Closed
Closed
Closed
Member
|
closing this in favor of #2438 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This doesn't handle all the edge cases (like expect continue) and trailers. Maybe less code than implementing a net.Listener? At least it's one goroutine.
Might switch to a net.Listener later.