Skip to content

Add initial prototype of http over libp2p#2218

Closed
MarcoPolo wants to merge 2 commits intomasterfrom
marco/p2p-http
Closed

Add initial prototype of http over libp2p#2218
MarcoPolo wants to merge 2 commits intomasterfrom
marco/p2p-http

Conversation

@MarcoPolo
Copy link
Collaborator

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.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

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)
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We get to reuse the whole thing here which is probably net better for the GC.

@p-shahi p-shahi linked an issue Mar 29, 2023 that may be closed by this pull request
@p-shahi p-shahi mentioned this pull request Jun 14, 2023
@p-shahi
Copy link
Member

p-shahi commented Jul 27, 2023

closing this in favor of #2438

@p-shahi p-shahi closed this Jul 27, 2023
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.

http: libp2p + http

3 participants