Hacker Newsnew | past | comments | ask | show | jobs | submit | aaronbee's commentslogin

The trade off is discussed here: https://github.com/golang/go/issues/70835


Your code is an example of a "pull iterator", and it's not as much of a concern.

The harder case to deal with is a "push iterator", which are often much simpler to implement, but less flexible to use. See https://github.com/golang/go/discussions/56413

The OP is about converting a push iterator into a pull iterator efficiently by using coroutines. This provides the best of both worlds, simple iterator implementation and flexible use by its caller.


There are some folks working on porting SwissTable to Go: https://github.com/golang/go/issues/54766

What’s holding it back currently is coming up with a way to do incremental rehash, which Go’s current map provides.


Here’s a description of the new map implementation and why it’s more efficient: https://www.pypy.org/posts/2015/01/faster-more-memory-effici...


Note that this applies more for python than efficient languages. In python, objects are big, and require an indirection. In faster languages, many objects can be smaller than a pointer and stored inline. As such, dictionaries that have vectorized lookups generally can be made faster.


Russ Cox has a few good explainer blog posts: https://research.swtch.com/mm


Many thanks.


I believe they made a mistake with that example. It doesn't look unsafe to me because the myResults sliced passed to the goroutine is not used. Or perhaps the racy part was left out of their snippet.

Below is what might be what they have meant. This code snippet is racy because an unsafe read of myResults is done to pass it to the goroutine and then that version of myResults is passed to safeAppend:

  func ProcessAll(uuids []string) {
    var myResults []string
    var mutex sync.Mutex
    safeAppend := func(results []string, res string) {
      mutex.Lock()
      myResults = append(myResults, res)
      mutex.Unlock()
    }

    for _, uuid := range uuids {
      go func(id string, results []string) {
        res := Foo(id)
        safeAppend(myResults, id)
      }(uuid, myResults) # <<< unsafe read of myResults
    } 
  }
EDIT: Formatting and clarity


Yea I think your read on the intent here is correct. I re-read that part five times wondering what I wasn't getting.


go1.18 is coming out soon with generics. The first release candidate came out 2 weeks ago. You can track the open issues here: https://github.com/golang/go/milestone/201


I believe the GP's point is that even with a 10,000x increase in data center energy consumption, the effect on ocean temperature is tiny.


Even more exciting, this is already present in go1.13. I believe the author of these slides made a mistake.

Here it is mentioned in go1.13 release notes: https://golang.org/doc/go1.13#compiler

And GitHub says the commit is present in go1.13: https://github.com/golang/go/commit/996a687ebbf81b26f81b41b8...


Yeah it is slightly misleading. The escape analysis rewrite was done in 1.13. But work is now going on to remove the old escape analysis code.


TCL is pronounced "tickle." https://en.wikipedia.org/wiki/Tcl


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: