Skip to content

Instantly share code, notes, and snippets.

View dim's full-sized avatar

Dimitrij Denissenko dim

View GitHub Profile
[
{
"name": "Afghanistan",
"alpha2": "AF",
"alpha3": "AFG",
"numeric": 4
},
{
"name": "Albania",
"alpha2": "AL",
@dim
dim / s2-cell-sizes.md
Created May 20, 2019 12:46
S2 Geometry Cell Sizes
export function sum(
forSomeReasonThisIsAVeryLongVariableName1: number,
forSomeReasonThisIsAVeryLongVariableName2: number,
): number {
return (
forSomeReasonThisIsAVeryLongVariableName1 +
forSomeReasonThisIsAVeryLongVariableName2
);
}
@dim
dim / Makefile
Last active November 25, 2019 13:15
Go(lang) non-cryptographic hash benchmark
default: bench
bench:
go test -run=NONE -bench=. -benchmem
@dim
dim / atomutex_test.go
Created February 28, 2017 16:49
Benchmark: sync.RWMutex vs atomic.Value
/*
Benchmark_RWMutex-4 100000000 18.1 ns/op
Benchmark_Atomic-4 200000000 8.01 ns/op
Benchmark_RWMutex_parallel-4 30000000 46.7 ns/op
Benchmark_Atomic_parallel-4 1000000000 2.61 ns/op
*/
package main
module RedisCluster
def self.crc16(bytes)
crc = 0
bytes.each_byte{|b|
crc = ((crc<<8) & 0xffff) ^ XMODEMCRC16Lookup[((crc>>8)^b) & 0xff]
}
crc
end
def self.slot(key)

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

# "Performance Scalability of a Multi-Core Web Server", Nov 2007
# Bryan Veal and Annie Foong, Intel Corporation, Page 4/10
fs.file-max = 5000000
net.core.netdev_max_backlog = 400000
net.core.optmem_max = 10000000
net.core.rmem_default = 10000000
net.core.rmem_max = 10000000
net.core.somaxconn = 100000
net.core.wmem_default = 10000000
net.core.wmem_max = 10000000
{
"IAB1": "Arts & Entertainment",
"IAB1-1": "Books & Literature",
"IAB1-2": "Celebrity Fan/Gossip",
"IAB1-3": "Fine Art",
"IAB1-4": "Humor",
"IAB1-5": "Movies",
"IAB1-6": "Music",
"IAB1-7": "Television",
"IAB2": "Automotive",
@dim
dim / redis-bitpos-benchmark.rb
Created October 1, 2013 08:10
Integration benchmark for redis BITPOS command
# Integration benchmark for redis BITPOS command
require 'redis'
require 'benchmark'
random = Random.new(1)
redis = Redis.new timeout: 60
bitlen = 10_000
tmpkey = "__rb__bs__"
server = File.expand_path('../src/redis-server', __FILE__)