Skip to content

Instantly share code, notes, and snippets.

View Dieterbe's full-sized avatar

Dieter Plaetinck Dieterbe

View GitHub Profile
@Dieterbe
Dieterbe / prepare-benchmarking.sh
Created April 26, 2018 14:21
I use this script to set up my system for benchmarking
#!/bin/bash
# useful articles:
# https://vstinner.github.io/journey-to-stable-benchmark-system.html
# http://perf.readthedocs.io/en/latest/system.html
# https://baiweiblog.wordpress.com/2017/11/02/how-to-set-processor-affinity-in-linux-using-taskset/
# https://wiki.archlinux.org/index.php/CPU_frequency_scaling#CPU_frequency_driver
if [[ $EUID > 0 ]]; then
echo "Please run as root"
exit 1
#!/bin/bash
echo "$(date) load 2kHz"
timeout 120 fakemetrics feed --gnet-addr http://localhost:9000/metrics --gnet-key not_very_secret_key --mpo 2000 --orgs 1
echo "$(date) load 20kHz"
timeout 120 fakemetrics feed --gnet-addr http://localhost:9000/metrics --gnet-key not_very_secret_key --mpo 20000 --orgs 1
go test -run=. -bench=.
goos: linux
goarch: amd64
BenchmarkUintsParse-8 10000000 162 ns/op
BenchmarkUintsPrint-8 5000000 337 ns/op
BenchmarkArrParse-8 10000000 151 ns/op
BenchmarkArrPrint-8 3000000 403 ns/op
PASS
ok _/home/dieter/tmp/string-to-byte-array 7.126s
1) for any request that returned non-"http 200 ok", see full request body (incl post data) and response headers and body
2) see last actions up to a crash (e.g. which requests were being handled and in what stage)
3) additional datapoints (e.g. amount of series and datapoints loaded to satisfy a request), for single queries (by id)
4) maybe: additional datapoints (e.g. amount of series and datapoints loaded to satisfy a request), aggregated per instance/across all instances
5) track all slow requests. show their full request, and show latencies. https://github.com/raintank/metrictank/issues/678
6) time spent in different systems/subroutines, for single queries (by id)
7) time spent in different systems/subroutines, aggregated per instance/across all instances
8) on-demand debug logs for specific requests https://github.com/raintank/metrictank/issues/360
we have various desires to make our logging better (use a maintained lib, structured logging, etc) see https://github.com/raintank/metrictank/issues/624
curl -v -H 'X-Org-Id: 1' "http://localhost:6070/render/?target=some.id.of.a.metric.*" | sed 's#,#\r\n#g' | grep target
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 6070 (#0)
> GET /render/?target=some.id.of.a.metric.* HTTP/1.1
> Host: localhost:6070
> User-Agent: curl/7.50.1
> Accept: */*
> X-Org-Id: 1
~ ❯❯❯ for i in {0..7}; do echo $i; curl -H 'X-Org-Id: 1' "http://localhost:607$i/metrics/index.json"; echo; done
0
[]
1
[]
2
["metrictank.usage.numPoints","metrictank.usage.numSeries","some.id.of.a.metric.2","some.id.of.a.metric.4","some.id.of.a.metric.7"]
3
["metrictank.usage.numPoints","metrictank.usage.numSeries","some.id.of.a.metric.1","some.id.of.a.metric.5","some.id.of.a.metric.8"]
4
==> Making package: vagrant-git 1.8.5.87.g9c299a2-1 (Tue Sep 13 18:18:48 EEST 2016)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Updating vagrant git repo...
Fetching origin
==> Validating source files with md5sums...
vagrant ... Skipped
==> Extracting sources...
-> Creating working copy of vagrant git repo...
~/g/s/g/r/worldping-api ❯❯❯ make ⏎
make all
make[1]: Entering directory '/home/dieter/go/src/github.com/raintank/worldping-api'
bash -c "./scripts/depends.sh"
+++ dirname ./scripts/depends.sh
++ cd ./scripts
++ pwd
+ DIR=/home/dieter/go/src/github.com/raintank/worldping-api/scripts
+ cd /home/dieter/go/src/github.com/raintank/worldping-api/scripts
+ : /home/dieter/go
package main
import (
"fmt"
"time"
)
func main() {
size := 100 * 1000 * 1000
data := make([][10]byte, size)
{
"id": null,
"title": "usage accounting",
"originalTitle": "usage accounting",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,