Thanks for concurrency improvements

552 views
Skip to first unread message

Gustavo Niemeyer

unread,
Aug 3, 2011, 8:35:28 AM8/3/11
to Dmitry Vyukov, golang-nuts
Hey Dmitry,

Just a quick public acknowledgement for your recent efforts in the
concurrency aspects of the runtime. I've just run a real world
benchmark provided by someone using mgo with the r59 release, and it
took about 5 seconds out of 20, without any changes in the code.

Please keep up the great work.

--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog

-- I never filed a patent.

jimr

unread,
Aug 3, 2011, 12:13:11 PM8/3/11
to golan...@googlegroups.com
This note caught my eye because I just had another experience where
the Go language just made my life a whole lot easier.  So I'd like to
follow up Gustavo's note by sending a general thank-you to the Go
developers for making such a nice language, period.

I have a program I'm working on that ends up using HTTP to POST or PUT
resources onto another server.  The general flow of the first draft of
the program was along the lines of:

    for id := range idSet {
        entry := generateEntry(id)
        if doUpdate(entry) {
            if u.Update(entry) {
                success[entry.URL] = true
            }
        }
    }

I found that this was far too slow, but I also found that if I faked
u.Update, to just write its data to /dev/null, the program was 25x
faster than when I actually sent data to the remote server.  That
seemed to indicate I was probably spending a lot of time blocking,
waiting on the remote server.

So with a few simple changes, thanks to Go's design, I added code to
spawn a few goroutines to handle the updates:

func (u *Updater) Updater(entries chan Representation, status chan map[string]bool) {
    m := make(map[string]bool)
    for entry := range entries {
        m[entry.URL()] = u.Update(entry)
    }
    status <- m
}

and code to submit entries to those goroutines:

....
    updateEntries := make(chan Representation)
    updateStatus := make(chan map[string]bool)
    for i := 0; i < u.Config.GoRoutines; i ++ {
        go u.Updater(updateEntries, updateStatus)
    }
....
    for id := range idSet {
        entry := generateEntry(id)
        if doUpdate(entry) {
            updateEntries <- entry
        }
    }
...
    close(updateEntries)
...

the code was able to execute many more operations per second. In
this case, with 3 goroutines, I see a 3x to 4x speed-up:

       HTTP UPDATES PER SECOND

SERIAL CODE           CONCURRENT CODE
Mean     : 16.1298    Mean     : 62.6208
StdDev   : 4.8292     StdDev   : 27.7307
Variance : 23.3216    Variance : 768.9911
Minimum  : 1.0000     Minimum  : 1.0000
Maximum  : 27.0000    Maximum  : 126.0000
Percentiles           Percentiles
     25% : 14.0000         25% : 45.0000
     50% : 17.0000         50% : 65.0000
     75% : 20.0000         75% : 83.0000
     95% : 22.0000         95% : 104.0000
     99% : 24.0000         99% : 113.0000

It's extremely nice to have a language that makes concurrency so easy
to use.

Jim

Brandon Mercer

unread,
Aug 3, 2011, 12:17:42 PM8/3/11
to golan...@googlegroups.com
My sentiments as well. I came from the "hardware is cheap" camp but it
seems a terrible waste what we do with it at times. Thanks for this
language, your hard work and giving us such a great tool that lets us
build stuff quickly, that runs quickly, and is easy to develop. :)
Brandon

Andrew Gerrand

unread,
Aug 3, 2011, 2:48:57 PM8/3/11
to golan...@googlegroups.com, Dmitry Vyukov
Indeed. Thanks for your excellent work, Dmitry.

Nice to see it paying off so quickly.

Andrew

Dave Cheney

unread,
Aug 3, 2011, 7:43:21 PM8/3/11
to golan...@googlegroups.com
I'd also like to give a note of public thanks to Dmitry for his
ongoing efforts improving the runtime. Your work is very much
appreciated and will benefit countless current and future Go users.

Cheers

Dave

Adriaan Wiers

unread,
Aug 3, 2011, 9:52:52 PM8/3/11
to golan...@googlegroups.com, Dmitry Vyukov
On Wednesday, August 3, 2011 9:35:28 AM UTC-3, Gustavo Niemeyer wrote:

Just a quick public acknowledgement for your recent efforts in the
concurrency aspects of the runtime.  I've just run a real world
benchmark provided by someone using mgo with the r59 release, and it
took about 5 seconds out of 20, without any changes in the code.


I second that and would also congratulate Gustavo. It is so much more common to see people complaining than recognizing good work. Kudos to both.

Adriaan.

Carl

unread,
Aug 4, 2011, 4:02:32 AM8/4/11
to golang-nuts
On 3 Aug., 14:35, Gustavo Niemeyer <gust...@niemeyer.net> wrote:
> Hey Dmitry,
>
> Just a quick public acknowledgement for your recent efforts in the
> concurrency aspects of the runtime.  I've just run a real world
> benchmark provided by someone using mgo with the r59 release, and it
> took about 5 seconds out of 20, without any changes in the code.
>
> Please keep up the great work.

5 seconds out of 20 is huge, I second the above acknowledgement!

The primary reason I took an interest in the Go language was because
of its concurrency and scalability perspectives...

Imagine if you are running thousands of Servers (or perhaps 900000
Servers) and you save just 10% or 20% of your processor time and
energy only by using more efficient algorithms on the concurrency
side. Calculate that into Dollars saved or even just emissions saved.
Its a compelling business case :-) .

Dmitry Vyukov

unread,
Aug 8, 2011, 3:01:57 PM8/8/11
to golan...@googlegroups.com, Dmitry Vyukov
On Wednesday, August 3, 2011 4:35:28 PM UTC+4, Gustavo Niemeyer wrote:
Hey Dmitry,

Just a quick public acknowledgement for your recent efforts in the
concurrency aspects of the runtime.  I've just run a real world
benchmark provided by someone using mgo with the r59 release, and it
took about 5 seconds out of 20, without any changes in the code.

Please keep up the great work.


Thank you, guys! You are welcome! It's really nice to hear such responses.
More is coming, stay tuned ;)

Btw, while you are here, I've started work on the concurrent "co" package, and would like to hear your thoughts on it, I will start a separate thread for it.

Martin Capitanio

unread,
Aug 8, 2011, 5:47:44 PM8/8/11
to golan...@googlegroups.com, Dmitry Vyukov
I just want to note that your web page is cool too.


Reply all
Reply to author
Forward
0 new messages