On Sun, Mar 5, 2017 at 2:41 AM,  <nickri...@gmail.com> wrote:
>
> TL;DR: The only option is to work with syscall package and build everything
> ground up, or there are some easier way?
>
> The story is, I'm working on a network related project
> (https://github.com/nickrio/coward) which been designed to take a lots of
> connections. Most of those connections is just idle, but hey can back to
> active at any time.
>
> Currently, that application is implemented in Go's style -- When a new
> connection is accepted, a new goroutine is created, along with associated
> buffer and structs.
>
> The downside of that is, I have to create a buffer for each goroutine (for
> each connection), no matter that connection is active or not. And because of
> that, there will be a lots of memory space been wasted (goroutine also cost
> few KB of memories).
>
> So I'm thinking, if I can somehow re-implement connection handling in
> epoll-like model, then I could save those idle memory for better memory
> efficiency.
>
> After dug few pages of source code on golang.org, I discover that in order
> to do so, I have to work with some *low* level system calls (the package
> name is literally syscall) and runtime package.
>
> So before I get started, I want to do the last check to make sure there are
> no any other way to go (No built-in package or x package will help me to do
> that. Sorry, I'm new to Golang, if there are a magic hidden inside, I
> probably wouldn't found it. So better ask to make sure), so I don't waste my
> time doing it.

I can confirm that there is no other way to go.

No matter what you have to keep some state in memory to describe each
connection.  Goroutines are fairly small.  They aren't free, but it is
an unusual program that requires something smaller.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to