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

Add initial prototype of http over libp2p #2218

Closed
wants to merge 2 commits into from
Closed

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.

p2p/http/responsewriter.go Show resolved Hide resolved
p2p/http/responsewriter.go Show resolved Hide resolved
@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