Skip to content

Instantly share code, notes, and snippets.

View gz's full-sized avatar

Gerd Zellweger gz

View GitHub Profile
{"id": 11, "from_account": 1, "to_account": 5, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 4, "from_account": 3, "to_account": 8, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 14, "from_account": 6, "to_account": 1, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 10, "from_account": 5, "to_account": 1, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 43, "from_account": 4, "to_account": 8, "amount": 1, "ts": "2021-01-01 00:00:02.000"}
{"id": 7, "from_account": 9, "to_account": 4, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 30, "from_account": 2, "to_account": 3, "amount": 1, "ts": "2021-01-01 00:00:01.000"}
{"id": 1, "from_account": 2, "to_account": 1, "amount": 1, "ts": "2021-01-01 00:00:00.000"}
{"id": 23, "from_account": 6, "to_account": 4, "amount": 1, "ts": "2021-01-01 00:00:01.000"}
{"id": 37, "from_account": 6, "to_account": 9, "amount": 1, "ts": "2021-01-01 00:00:02.000"}

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@gz
gz / perf.md
Last active October 21, 2023 06:21
On using perf

Setup

Avoid annoying security settings:

sudo sh -c 'echo 0 >> /proc/sys/kernel/kptr_restrict'
sudo sh -c 'echo 0 > /proc/sys/kernel/nmi_watchdog'
sudo sh -c 'echo -1 > /proc/sys/kernel/perf_event_paranoid'
echo 1 | sudo tee /proc/sys/kernel/sched_schedstats
@gz
gz / files.rs
Created February 4, 2023 07:08
some ways to read files in rust, mmap is fastest
use std::time::Instant;
use std::fs::File;
use std::io::{self, prelude::*, BufReader};
let file = File::open("examples/WDC_tickbidask.csv")?;
let mut reader = BufReader::new(file);
let mut line = String::new();
let mut lines = 0;
let start = Instant::now();
while reader.read_line(&mut line).unwrap() > 0 {
@gz
gz / gist:33ffec50370c9f61180b37a3d010e3a4
Created April 11, 2021 05:18
Forgot VM image password
sudo apt install libguestfs-tools
virt-customize -a bionic-server-cloudimg-amd64.img --root-password password:<newpass>

Rust Workshop set-up instructions

Hi, these are the setup instructions for the rust workshop. This is the (hopefully) bullet-proof way to get everything you need for Thursday (and still have it working on Thursday). If you run into issues, check the FAQ section.

Note: If you don't like to use Docker, see below for an alternative method.

Install Docker itself if you don't have it already

@gz
gz / t1_vs_t8.log
Created June 25, 2020 00:24
NR HT 100% thread analysis (AVG)
Events that predominantly trigger in thread8 and not in thread1
Event name: Fraction (progB - progA = difference)
=================================================
AVG.UNC_CHA_RxR_CRD_STARVED.AD_CRD: 0.95 (6.107142857142857-0.3214285714285714=5.785714285714286)
AVG.UOPS_EXECUTED.CORE: 0.95 (6583791188.660714-339388256.32142854=6244402932.339286)
AVG.UOPS_RETIRED.RETIRE_SLOTS: 0.95 (3101525057.892857-159643437.71428573=2941881620.178571)
AVG.UNC_M2M_DIRECTORY_UPDATE.ANY: 0.95 (430443.5-21672.75=408770.75)
AVG.UNC_CHA_SF_EVICTION.S_STATE: 0.95 (124.03571428571428-6.107142857142858=117.92857142857142)
AVG.L2_RQSTS.PF_HIT: 0.95 (1403203.6964285716-68851.16071428571=1334352.535714286)
@gz
gz / t1_vs_t2.log
Last active June 25, 2020 00:03
nr autoperf run 100% write HT
Events that predominantly trigger in thread2 and not in thread1
Event name: Fraction (progB - progA = difference)
=================================================
MAX.UNC_M2M_RxR_OCCUPANCY.AK_BNC: 0.95 (182665.0-9496.0=173169.0)
MAX.UNC_M2M_AG1_BL_CRD_OCCUPANCY.TGR2: 0.95 (4870730.0-251402.0=4619328.0)
MAX.UNC_M2M_RxR_INSERTS.AK_BNC: 0.95 (231112.0-11920.0=219192.0)
MAX.UNC_M2M_HORZ_RING_IV_IN_USE.RIGHT: 0.95 (63167.0-3218.0=59949.0)
MAX.UNC_CHA_XSNP_RESP.EVICT_RSP_HITFSE: 0.95 (2262.0-115.0=2147.0)
MAX.UNC_M2M_RING_BOUNCES_VERT.AD: 0.95 (455.0-23.0=432.0)
set -ex
sudo apt-get build-dep libmemcached-tools
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18/
LDFLAGS='-lpthread' CXXFLAGS='-fpermissive' CFLAGS='-Wno-errors -fpermissive' ./configure --enable-memaslap --with-pthread=yes
make -j12
sudo make install
sudo ldconfig
{"index":{"0":0,"1":1,"2":0,"3":1,"4":0,"5":1,"6":0,"7":1,"8":0,"9":1,"10":0,"11":1,"12":0,"13":1,"14":1,"15":0,"16":0,"17":1,"18":0,"19":1,"20":0,"21":1,"22":1,"23":0,"24":0,"25":1,"26":0,"27":1,"28":0,"29":1,"30":0,"31":1,"32":1,"33":0,"34":0,"35":1,"36":0,"37":1,"38":0,"39":1,"40":1,"41":0,"42":0,"43":1,"44":0,"45":1,"46":0,"47":1,"48":0,"49":1,"50":1,"51":0,"52":0,"53":1,"54":0,"55":1,"56":0,"57":1,"58":0,"59":1,"60":0,"61":1,"62":0,"63":1,"64":0,"65":1,"66":0,"67":1},"git_rev":{"0":"9b7d0f9b1e9164d84a626fe71bc04f7904e5b5ca","1":"9b7d0f9b1e9164d84a626fe71bc04f7904e5b5ca","2":"67453cd54b8fd74c93eb76a6f6c9722ef3f94654","3":"67453cd54b8fd74c93eb76a6f6c9722ef3f94654","4":"4a4f19795e7148c5e6401bbb2c021d6e59622cfb","5":"4a4f19795e7148c5e6401bbb2c021d6e59622cfb","6":"71977e090df83fdcc1d14c7a685147b4310ff810","7":"71977e090df83fdcc1d14c7a685147b4310ff810","8":"89f2af68f99947822ccc0ae4012662fe72d10b57","9":"89f2af68f99947822ccc0ae4012662fe72d10b57","10":"8f8890e82f6fd16e794a9725c679e2054ed74ff5","11":"8f8890e82f6f