#Create bitbucket branch
##Create local branch
$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
master
* sync
#Create bitbucket branch
##Create local branch
$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
master
* sync
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.
In a project I'm working on I ran into the requirement of having some sort of persistent FIFO buffer or pipe in Linux, i.e. something file-like that could accept writes from a process and persist it to disk until a second process reads (and acknowledges) it. The persistence should be both across process restarts as well as OS restarts.
AFAICT unfortunately in the Linux world such a primitive does not exist (named pipes/FIFOs do not persist
#include <stdint.h> | |
/* | |
Fast 64bit integer log10 | |
WARNING: calling ilog10c(0) yields undefined behaviour! | |
On x64 this compiles down to: | |
pushq %rbp |
from flask import after_this_request, request | |
from cStringIO import StringIO as IO | |
import gzip | |
import functools | |
def gzipped(f): | |
@functools.wraps(f) | |
def view_func(*args, **kwargs): | |
@after_this_request | |
def zipper(response): |
import brotli | |
def main(request, response): | |
if "content" in request.GET: | |
output = request.GET["content"] | |
else: | |
output = request.body | |
output = brotli.compress(output) | |
headers = [("Content-type", "text/plain"), |
./mach cargo-update -p brotli --precise 0.3.17 | |
components/servo | |
thread '<main>' panicked at 'index 0 and/or 8 in `0.3.17` do not lie on character boundary', ../src/libcore/str/mod.rs:1284 |
#include <stdio.h> | |
#define STR2(x) #x | |
#define STR(x) STR2(x) | |
#define INCBIN(name, file) \ | |
__asm__(".section .rodata\n" \ | |
".global incbin_" STR(name) "_start\n" \ | |
".type incbin_" STR(name) "_start, @object\n" \ | |
".balign 16\n" \ |
I hereby claim:
To claim this, I am signing this object:
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs