Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

siddontang siddontang

🏠
Working from home
Block or report user

Report or block siddontang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@siddontang
siddontang / BPF.txt
Last active Sep 23, 2019
BPF Performance Tools
View BPF.txt
Hello BPF
@siddontang
siddontang / tcptop.py
Created Sep 11, 2019
add count statistics for bcc tcptop
View tcptop.py
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# tcptop Summarize TCP send/recv throughput by host.
# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: tcptop [-h] [-C] [-S] [-p PID] [interval [count]]
#
# This uses dynamic tracing of kernel functions, and will need to be updated
# to match kernel changes.
@siddontang
siddontang / tikv_memleak.py
Created Sep 11, 2019
bcc memleak for TiKV
View tikv_memleak.py
#!/usr/bin/python
#
# memleak Trace and display outstanding allocations to detect
# memory leaks in user-mode processes and the kernel.
#
# USAGE: memleak [-h] [-p PID] [-t] [-a] [-o OLDER] [-c COMMAND]
# [--combined-only] [-s SAMPLE_RATE] [-T TOP] [-z MIN_SIZE]
# [-Z MAX_SIZE] [-O OBJ]
# [interval] [count]
#
View alloc_backtrace.rs
extern crate backtrace;
extern crate libc;
use backtrace::BytesOrWideString;
use std::alloc::{System, GlobalAlloc, Layout};
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
struct Counter;
static ALLOCATED: AtomicUsize = AtomicUsize::new(0);
@siddontang
siddontang / tidb-to-loki.go
Created Jul 21, 2019
Sync TiDB logs to Loki
View tidb-to-loki.go
package main
import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"net/http"
View build_on_arm.sh
ROOT=$PWD/build
rm -rf $ROOT
mkdir -p $ROOT
cd $ROOT
# Go
if which go >/dev/null; then
echo "go installed, skip"
else
View monitor_binary_cluster.md

Preparation

Assume you have already deployed PD, TiKV, Prometheus and Grafana.

PD: 127.0.0.1:2379 TiKV: 127.0.0.1:20181, 127.0.0.1:20182, 127.0.0.1:20183 Prometheus: 127.0.0.1:9090 Grafana: 127.0.0.1:3000

Prometheus Config

View dtrace.md

Using dtrace to profile your program on Mac OSX.

Prepare

wget https://github.com/brendangregg/FlameGraph/archive/master.zip
unzip master.zip 
mv FlameGraph-master FlameGraph

wget https://raw.githubusercontent.com/siddontang/gprof2dot/master/gprof2dot.py
@siddontang
siddontang / gen_tikv_dockerfile.sh
Created Apr 28, 2019
A script to generate TiKV dockerfile
View gen_tikv_dockerfile.sh
# TiKV root
dir="."
output="./Dockerfile"
if [ "$#" -eq 1 ]; then
output=$1
fi
cat <<EOT > ${output}
FROM pingcap/rust as builder
View cpu.md

Common

#!/bin/bash

perf record -F 99 -p $1 -g -- sleep 60
perf script > out.perf
/opt/FlameGraph/stackcollapse-perf.pl out.perf > out.folded
/opt/FlameGraph/flamegraph.pl out.folded > cpu.svg
curl --upload-file ./cpu.svg https://transfer.sh/cpu.svg
You can’t perform that action at this time.