Skip to content

Instantly share code, notes, and snippets.

@nicksherron
nicksherron / disable-transparent-huge-pages.service
Last active January 22, 2024 21:32
systemd service for disabling Transparent Huge Pages (THP) for dbs like mongodb and redis
[Unit]
Description=Disable Transparent Huge Pages (THP)
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=mongod.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null'
@liemle3893
liemle3893 / .gitlab-ci.yml
Created April 1, 2020 12:27
Gitlab CI with Nomad
# Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh
# runtime for each build is more reliable since the runtime is completely
# isolated from any previous builds.
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
DOCKER_TLS_CERTDIR: ""
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
@neomantra
neomantra / High_Performance_Redis.md
Last active February 7, 2024 03:41
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@takatoshiono
takatoshiono / copy-digits.go
Last active December 28, 2022 00:19
CopyDigits function ref
package main
// ref: https://blog.golang.org/go-slices-usage-and-internals
// 1234 <-- digits
import (
"fmt"
"io/ioutil"
"regexp"
)

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
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 4X memory