Skip to content

Instantly share code, notes, and snippets.

View ruiaylin's full-sized avatar

Lin RuiChao ruiaylin

View GitHub Profile
@ruiaylin
ruiaylin / daemon.md
Created September 11, 2018 06:23 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.

{"sig":"d0b46247bf218c3e5dfc37c8afa66baabc2b5115e9e09a77d526b1ee5e82c7dc2c1bcc9c38024df3506a06c40ae80f937dd7f34678743b0d47405f7c444309b20","msghash":"8cd43b3cc730de918f2e291b7d951d95279b13809e1114e3324b45b8eb6d3552"}

Latency numbers every programmer should know

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