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

Comments

Projects
None yet
3 participants
@tema3210
Copy link

commented Jan 26, 2019

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

This comment has been minimized.

Copy link

commented Jan 26, 2019

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

This comment has been minimized.

Copy link
Author

commented Jan 26, 2019

@networkimprov thanks, it's helpful

@tema3210

This comment has been minimized.

Copy link
Author

commented Jan 26, 2019

@networkimprov and where i can read about special cases?

@networkimprov

This comment has been minimized.

Copy link

commented Jan 26, 2019

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

This comment has been minimized.

Copy link
Author

commented Jan 26, 2019

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

This comment has been minimized.

Copy link
Member

commented Jan 26, 2019

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

@bradfitz bradfitz closed this Jan 26, 2019

@mikioh mikioh changed the title net.Conn add tryRead() method net: add tryRead() method to Conn Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.