Skip to content

Instantly share code, notes, and snippets.

View gz's full-sized avatar

Gerd Zellweger gz

View GitHub Profile
@gz
gz / program.sql
Created January 8, 2025 16:16
xls code
create table spreadsheet_data (
id bigint not null,
ts timestamp not null,
raw_value varchar(64) not null
) with (
'materialized' = 'true',
'connectors' = '[{
"transport": {
"name": "datagen",
"config": {
{"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