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
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
@siddontang
siddontang / workloads_example.txt
Last active Jan 13, 2019
Code for go-ycsb article
View workloads_example.txt
+--------------------+--------------------------+---------------------+--------------------------+
| Workload | Operations | Record selection | Application example |
+--------------------+--------------------------+---------------------+--------------------------+
| A — Update heavy | Read: 50%, Update: 50% | Zipfian | User Session |
| B — Read heavy | Read: 95%, Update: 5% | Zipfian | Photo tagging |
| C — Read only | Read: 100% | Zipfian | User profile cache |
| D — Read latest | Read: 95%, Insert: 5% | Latest | User status updates |
| E — Short range | Scan: 95%, Insert: 5% | Zipfian / Uniform | Threaded conversations |
+--------------------+--------------------------+---------------------+--------------------------+
@siddontang
siddontang / capture
Last active Apr 11, 2019
A tool to capture TiKV gRPC message
View capture
go run tikv-assembly.go -f "port 20160" -i lo0
2018/12/29 20:17:17 Starting capture on interface "lo0"
2018/12/29 20:17:17 reading in packets
2018/12/29 20:17:26 127.0.0.1:64989 -> 127.0.0.1:20160 /tikvpb.Tikv/KvPrewrite context:<region_id:2 region_epoch:<conf_ver:1 version:1 > peer:<id:3 store_id:1 > > mutations:<key:"usertable:a" value:"\010\000\002\0020" > primary_lock:"usertable:a" start_version:405297128206237697 lock_ttl:3000
2018/12/29 20:17:26 127.0.0.1:20160 -> 127.0.0.1:64989 /tikvpb.Tikv/KvPrewrite
2018/12/29 20:17:26 127.0.0.1:64995 -> 127.0.0.1:20160 /tikvpb.Tikv/KvCommit context:<region_id:2 region_epoch:<conf_ver:1 version:1 > peer:<id:3 store_id:1 > > start_version:405297128206237697 keys:"usertable:a" commit_version:405297128206237698
2018/12/29 20:17:26 127.0.0.1:20160 -> 127.0.0.1:64995 /tikvpb.Tikv/KvCommit
2018/12/29 20:17:29 127.0.0.1:64999 -> 127.0.0.1:20160 /tikvpb.Tikv/KvGet context:<region_id:2 region_epoch:<conf_ver:1 version:1 > peer:<id:3 store_id:1 > > key:"usertable:a" version:4
View mutex_atomic.go
package main
import (
"sync"
"sync/atomic"
"testing"
)
func main() {
// Parallel benchmark for text/template.Template.Execute on a single object.
You can’t perform that action at this time.