Skip to content

Instantly share code, notes, and snippets.

View siddontang's full-sized avatar
🏠
Working from home

siddontang siddontang

🏠
Working from home
  • PingCAP
  • SunnyVale
View GitHub Profile
package main
import (
"sync"
"sync/atomic"
"testing"
)
func main() {
// Parallel benchmark for text/template.Template.Execute on a single object.
@siddontang
siddontang / fnbox_fnonce.rs
Created August 31, 2018 01:23
Test how to use FnOnce instead of FnBox
#![feature(test)]
extern crate test;
use std::ops::FnOnce;
use std::sync::mpsc;
use std::thread;
pub trait FnBox {
fn call_box(self: Box<Self>);
@siddontang
siddontang / cpu_tenancy.py
Last active July 24, 2018 13:49
A tool to show how the thread runs on different CPUs
#!/usr/bin/python
import sys
import re
# perf record -F 99 -p $1 -e "sched:sched_stat_runtime" -a -- sleep 20
# perf script -F comm,pid,tid,cpu,time | python cpu_tenancy.py
#
# time-monitor-wo 79618/79634 [007] 11994704.695317:
# grpc-server-1 79618/79954 [006] 11994704.717969:
package prefix_access
import (
"bytes"
"encoding/binary"
"testing"
)
func hasPrefix(buf []byte, prefix []byte) bool {
return buf[0] == prefix[0] && buf[1] == prefix[1]
public Status read(String table, String key, Set<String> fields,
Map<String, ByteIterator> result) {
try (final TraceScope span = tracer.newScope(scopeStringRead)) {
long ist = measurements.getIntendedtartTimeNs();
long st = System.nanoTime();
Status res = db.read(table, key, fields, result);
long en = System.nanoTime();
measure("READ", res, ist, st, en);
measurements.reportStatus("READ", res);
return res;
private void throttleNanos(long startTimeNanos) {
//throttle the operations
if (_targetOpsPerMs > 0)
{
// delay until next tick
long deadline = startTimeNanos + _opsdone*_targetOpsTickNs;
sleepUntil(deadline);
_measurements.setIntendedStartTimeNs(deadline);
}
}
func (db *fDB) Read(ctx context.Context, table string, key string, fields []string) (map[string][]byte, error) {
rowKey := db.getRowKey(table, key)
row, err := db.db.Transact(func(tr fdb.Transaction) (interface{}, error) {
f := tr.Get(fdb.Key(rowKey))
return f.Get()
})
if err != nil {
return nil, err
} else if row == nil {
Type QPS Avg(us) 95th(us) 99th(us)
Load 24828.4 4002 7000 9000
Update 5430.2 708 3000 6000
99% Read, 1% Insert - Read 19315.9 397 1000 2000
99% Read, 1% Insert - Insert 2139.0 1031 2000 3000
99% Read, 1% Insert, 100 Threads - Read 36904.7 2345 4000 6000
99% Read, 1% Insert, 100 Threads - Insert 4120.4 3081 5000 7000
Read 28010.3 353 1000 2000
Scan 1000 keys 1960.8 327 9000 10000

One FoundationDB, One TiKV.

recordcount=1000000
operationcount=1000000
workload=core

fieldcount=1
fieldlength=16
probe begin {
warn("Begin to trace jemalloc.\n")
}
probe process.function("malloc").return,
process.function("mallocx").return{
if (pid() != target()) next
printf("malloc: %p, bytes: %d\n", $return, @entry($size))