Skip to content

Instantly share code, notes, and snippets.

@nxnfufunezn
nxnfufunezn / log10.c
Last active September 13, 2015 10:53 — forked from CAFxX/log10.c
Fast integer log10 in C
#include <stdint.h>
/*
Fast 64bit integer log10
WARNING: calling ilog10c(0) yields undefined behaviour!
On x64 this compiles down to:
pushq %rbp
@nxnfufunezn
nxnfufunezn / persistent_pipes_linux.md
Last active September 13, 2015 10:50 — forked from CAFxX/persistent_pipes_linux.md
Persistent pipes/circular buffers for Linux

Persistent "pipes" in Linux

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

@nxnfufunezn
nxnfufunezn / README.md
Last active August 29, 2015 14:20 — forked from jonhoo/README.md

Distributed Read-Write Mutex in Go

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.

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync