Skip to content

Instantly share code, notes, and snippets.

View mopemope's full-sized avatar
🏠
Working from home

Yutaka Matsubara mopemope

🏠
Working from home
View GitHub Profile
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

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

@HarryR
HarryR / redis-parser.rl
Created January 2, 2012 16:50
Redis server-side protocol parser for Ragel
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
%%{
machine redis_parser;
action reset_line {
Index: ../Python/pythonrun.c
===================================================================
--- ../Python/pythonrun.c (revision 82245)
+++ ../Python/pythonrun.c (working copy)
@@ -1334,6 +1334,7 @@
return ret;
}
+bool toplevel = true;
static PyObject *
Coro: class {
// this was originally commented '128k needed on PPC due to parser'
// I have no idea what that means but 128k sounds reasonable.
DEFAULT_STACK_SIZE := static 128 * 1_024
MIN_STACK_SIZE := static 8_192
requestedStackSize: SizeT { get set }
allocatedStackSize: SizeT
@somic
somic / udp_hole_punch_tester.py
Created November 3, 2009 04:13
UDP Hole Punching test tool
#!/usr/bin/env python
#
# udp_hole_punch_tester.py - UDP Hole Punching test tool
#
# Usage: udp_hole_punch_tester.py remote_host remote_port
#
# Run this script simultaneously on 2 hosts to test if they can punch
# a UDP hole to each other.
#
# * remote_port should be identical on 2 hosts.