The default Go implementation of
sync.RWMutex does not scale well
to multiple cores, as all readers contend on the same memory location
when they all try to atomically increment it. This gist explores an
n
-way RWMutex, also known as a "big reader" lock, which gives each
CPU core its own RWMutex. Readers take only a read lock local to their
core, whereas writers must take all locks in order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/EverythingMe/inbloom/go/inbloom" | |
"net/http" | |
) | |
var vocabulary = []string{"foo", "bar", "baz", "hey", "yo", "go"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"fmt" | |
"time" | |
"github.com/EverythingMe/go-disque/disque" | |
"github.com/garyburd/redigo/redis" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package redis | |
import ( | |
"fmt" | |
"github.com/garyburd/redigo/redis" | |
) | |
// Batch represents a set of batched results, either a transaction or just send/receive. | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"fmt" | |
"runtime" | |
"io/ioutil" | |
"bytes" | |
"strings" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import time | |
import sys | |
def parent(): | |
p = subprocess.Popen(['python', './testp.py', '--child'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
NewerOlder