Using dtrace to profile your program on Mac OSX.
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
package bigetc | |
import ( | |
"database/sql" | |
"time" | |
"github.com/c4pt0r/log" | |
_ "github.com/go-sql-driver/mysql" | |
) |
ROOT=$PWD/build | |
rm -rf $ROOT | |
mkdir -p $ROOT | |
cd $ROOT | |
# Go | |
if which go >/dev/null; then | |
echo "go installed, skip" | |
else |
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 |
#!/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. |
#!/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] | |
# |
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); |
package main | |
import ( | |
"bufio" | |
"bytes" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"io" | |
"net/http" |
package main | |
import ( | |
"bytes" | |
"encoding/gob" | |
"reflect" | |
) | |
func RemoteOnline(id uint64) (uint64, string) { | |
return id, "abc" |