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

net: add tryRead() method to Conn #29947

Closed
tema3210 opened this issue Jan 26, 2019 · 6 comments
Closed

net: add tryRead() method to Conn #29947

tema3210 opened this issue Jan 26, 2019 · 6 comments

Comments

@tema3210
Copy link

On my last project i were very discouraged by the feature of test connection for the data is present is absent from language. We needed high perfomance, around 1-2 millions of connections, but we have to look for the third party libraries for epoll/kqueue integration in order to get the way to read and do something with data only when it's arrived, not waiting, such decision was made because even waiting goroutines in this case take around 4-8 GB of wasted memory.

P.S add such thing for tls.conn to.

@networkimprov
Copy link

Or perhaps a special case of make(chan) which takes io.Reader objects and provides the next readable member via <-c

func f(list ...net.Conn) error {
   c := make(chan, list...)
   buf := make([]byte, kSize)

   for r := range c {
      len, err := r.Read(buf)
      if err != nil { return err }
      something(buf[:len])
   }
}

@tema3210
Copy link
Author

@networkimprov thanks, it's helpful

@tema3210
Copy link
Author

@networkimprov and where i can read about special cases?

@networkimprov
Copy link

What I suggested would require a change to the language, so doesn't help right now.

This is also raised in #15735 by @bradfitz

@tema3210
Copy link
Author

Or perhaps a special case of make(chan) which takes io.Reader objects and provides the next readable member via <-c

func f(list ...net.Conn) error {
   c := make(chan, list...)
   buf := make([]byte, kSize)

   for r := range c {
      len, err := r.Read(buf)
      if err != nil { return err }
      something(buf[:len])
   }
}

And how do i add net.Conn's to such channel?

@bradfitz
Copy link
Contributor

Let's take this discussion to golang-nuts. We already have #15735 and I don't see anything new here.

@mikioh mikioh changed the title net.Conn add tryRead() method net: add tryRead() method to Conn Feb 26, 2019
@golang golang locked and limited conversation to collaborators Feb 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants