HN user

aaronbee

124 karma
Posts5
Comments25
View on HN
Coroutines for Go 3 years ago

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.

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

This suggests that Google/Facebook/Twitter will still be able to track you, assuming you use their websites regularly, but advertising companies that don't have pages frequented by the average internet user won't.

The problem with soft-links is that if the underlying file/directory is deleted, you are screwed. For example if you have 100 full-machine backups and want to free some space so you decide to delete every other one, you have to be careful that none of the backups you are keeping, have soft-links to files in the backups you are deleting.

With hard-links the underlying data is not deleted until all hard-links are deleted, so you can delete any individual backup directory without losing data in any other backup directory.

A soft-link is like a pointer in C whereas a hard-link is like a C++ shared_ptr, ie. reference counted.

X32 ABI 13 years ago

Another relevant benchmark is x32 vs. x86. In a memory constrained environment you may be forced to use x86. x32 gives you the ability to get the performance benefits of x86-64 (possibly plus some) while staying in your memory constraints.

Every packet goes through special switching hardware or ASIC. This ASIC has a pipeline for processing packets like a CPU has a pipeline for processing instructions. The ASIC also contains very fast tables optimized for storing and looking up MAC and IP addresses.

One part of the pipeline checks if the destination MAC matches the switch's MAC. If it does then the packet is routed and the ASIC will read the destination IP address from the packet. The dest IP is looked up in the routing table to figure out which port the next hop lives on and what it's MAC address is. If the destination MAC is for another host, then the MAC table is checked to see what port to send the mac.

Modern ASICs are designed to handle both cases very quickly.