Commit 2d13818e authored by Kirill Smelkov's avatar Kirill Smelkov

X bench-local + zhash: Add output in std bench format

parent cd2cd093
...@@ -773,35 +773,37 @@ Benchmark$1-avg 1 \\3 \\4/op\ ...@@ -773,35 +773,37 @@ Benchmark$1-avg 1 \\3 \\4/op\
hashfunc=crc32 hashfunc=crc32
#hashfunc=null #hashfunc=null
# bench <url> - run ZODB client benchmarks against URL # bench <topic> <url> - run ZODB client benchmarks against URL
bench() { bench() {
# XXX show C states usage diff after each benchmark XXX + same for P-states # XXX show C states usage diff after each benchmark XXX + same for P-states
# XXX +cpufreq transition statistics (CPU_FREQ_STAT) # XXX +cpufreq transition statistics (CPU_FREQ_STAT)
# XXX place=? # XXX place=?
url=$1 topic=$1
url=$2
# nrun time demo-zbigarray read $url # nrun time demo-zbigarray read $url
nrun ./zhash.py --$hashfunc $url nrun ./zhash.py --bench=$topic/%s --$hashfunc $url
echo -e "\n# ${Npar} clients in parallel" echo -e "\n# ${Npar} clients in parallel"
nrunpar ./zhash.py --$hashfunc $url nrunpar ./zhash.py --bench=$topic/%s-P$Npar --$hashfunc $url
if [[ $url == zeo://* ]]; then if [[ $url == zeo://* ]]; then
echo "(skipping zhash.go on ZEO -- Cgo does not support zeo:// protocol)" echo "(skipping zhash.go on ZEO -- Cgo does not support zeo:// protocol)"
return return
fi fi
echo echo
bench_go $url bench_go $topic $url
} }
# go-only part of bench # go-only part of bench
bench_go() { bench_go() {
url=$1 topic=$1
nrun ./zhash_go --log_dir=$log -$hashfunc $url url=$2
nrun ./zhash_go --log_dir=$log -$hashfunc -useprefetch $url nrun ./zhash_go --bench=$topic/%s --log_dir=$log -$hashfunc $url
nrun ./zhash_go --bench=$topic/%s --log_dir=$log -$hashfunc -useprefetch $url
echo -e "\n# ${Npar} clients in parallel" echo -e "\n# ${Npar} clients in parallel"
nrunpar ./zhash_go --log_dir=$log -$hashfunc $url nrunpar ./zhash_go --bench=$topic/%s-P$Npar --log_dir=$log -$hashfunc $url
} }
...@@ -816,36 +818,36 @@ cmd_bench-local() { ...@@ -816,36 +818,36 @@ cmd_bench-local() {
gen_data gen_data
echo -e "\n*** FileStorage" echo -e "\n*** FileStorage"
bench $fs1/data.fs bench `hostname`/fs1 $fs1/data.fs
echo -e "\n*** ZEO" echo -e "\n*** ZEO"
Zpy $fs1/data.fs Zpy $fs1/data.fs
bench zeo://$Zbind bench `hostname`/zeo zeo://$Zbind
killall runzeo killall runzeo
wait wait
echo -e "\n*** NEO/py sqlite" echo -e "\n*** NEO/py sqlite"
NEOpylite NEOpylite
bench neo://$cluster@$Mbind bench `hostname`/neo/py/sqlite neo://$cluster@$Mbind
xneoctl set cluster stopping xneoctl set cluster stopping
wait wait
echo -e "\n*** NEO/py sql" echo -e "\n*** NEO/py sql"
NEOpysql NEOpysql
bench neo://$cluster@$Mbind bench `hostname`/neo/py/sql neo://$cluster@$Mbind
xneoctl set cluster stopping xneoctl set cluster stopping
xmysql -e "SHUTDOWN" xmysql -e "SHUTDOWN"
wait wait
echo -e "\n*** NEO/go" echo -e "\n*** NEO/go"
NEOgo NEOgo
bench neo://$cluster@$Mbind bench `hostname`/neo/go neo://$cluster@$Mbind
xneoctl set cluster stopping xneoctl set cluster stopping
wait wait
echo -e "\n*** NEO/go (sha1 disabled)" echo -e "\n*** NEO/go (sha1 disabled)"
X_NEOGO_SHA1_SKIP=y NEOgo X_NEOGO_SHA1_SKIP=y NEOgo
X_NEOGO_SHA1_SKIP=y bench_go neo://$cluster@$Mbind X_NEOGO_SHA1_SKIP=y bench_go "`hostname`/neo/go(!sha1)" neo://$cluster@$Mbind
xneoctl set cluster stopping xneoctl set cluster stopping
wait wait
...@@ -981,10 +983,11 @@ cmd_run-client() { ...@@ -981,10 +983,11 @@ cmd_run-client() {
;; ;;
esac esac
url=$1 topic=$1
test -z "$url" && die "Usage: neotest run-client <url>" url=$2
test -z "$topic" -o -z "$url" && die "Usage: neotest run-client <topic> <url>"
test -z "$goonly" && bench $url || bench_go $url test -z "$goonly" && bench $topic $url || bench_go $topic $url
} }
# command: benchmark local disk # command: benchmark local disk
......
...@@ -69,6 +69,7 @@ func main() { ...@@ -69,6 +69,7 @@ func main() {
fsha1 := flag.Bool("sha1", false, "compute SHA1 cryptographic hash") fsha1 := flag.Bool("sha1", false, "compute SHA1 cryptographic hash")
fsha256 := flag.Bool("sha256", false, "compute SHA256 cryptographic hash") fsha256 := flag.Bool("sha256", false, "compute SHA256 cryptographic hash")
fsha512 := flag.Bool("sha512", false, "compute SHA512 cryptographic hash") fsha512 := flag.Bool("sha512", false, "compute SHA512 cryptographic hash")
fbench := flag.String("bench", "", "use benchmarking format for output")
useprefetch := flag.Bool("useprefetch", false, "prefetch loaded objects") useprefetch := flag.Bool("useprefetch", false, "prefetch loaded objects")
flag.Parse() flag.Parse()
...@@ -104,13 +105,13 @@ func main() { ...@@ -104,13 +105,13 @@ func main() {
log.Fatal(ctx, "no hash function specified") log.Fatal(ctx, "no hash function specified")
} }
err := zhash(ctx, url, h, *useprefetch) err := zhash(ctx, url, h, *useprefetch, *fbench)
if err != nil { if err != nil {
log.Fatal(ctx, err) log.Fatal(ctx, err)
} }
} }
func zhash(ctx context.Context, url string, h hasher, useprefetch bool) (err error) { func zhash(ctx context.Context, url string, h hasher, useprefetch bool, bench string) (err error) {
defer task.Running(&ctx, "zhash")(&err) defer task.Running(&ctx, "zhash")(&err)
stor, err := zodb.OpenStorageURL(ctx, url) stor, err := zodb.OpenStorageURL(ctx, url)
...@@ -218,10 +219,17 @@ loop: ...@@ -218,10 +219,17 @@ loop:
x := "zhash.go" x := "zhash.go"
if useprefetch { if useprefetch {
x += fmt.Sprintf(" +prefetch%d", nprefetch) x += fmt.Sprintf("+prefetch%d", nprefetch)
} }
if bench == "" {
fmt.Printf("%s:%x ; oid=0..%d nread=%d t=%s (%s / object) x=%s\n", fmt.Printf("%s:%x ; oid=0..%d nread=%d t=%s (%s / object) x=%s\n",
h.name, h.Sum(nil), oid-1, nread, δt, δt / time.Duration(oid), x) // XXX /oid cast ? h.name, h.Sum(nil), oid-1, nread, δt, δt / time.Duration(oid), x) // XXX /oid cast ?
} else {
topic := fmt.Sprintf(bench, x) // XXX -> better text/template
fmt.Printf("Benchmark%s 1 %.1f µs/object\t# %s:%x oid=0..%d nread=%d t=%s\n",
topic, float64(δt) / float64(oid) / float64(time.Microsecond),
h.name, h.Sum(nil), oid-1, nread, δt)
}
return nil return nil
} }
...@@ -90,22 +90,29 @@ options: ...@@ -90,22 +90,29 @@ options:
--sha1 compute SHA1 cryptographic hash --sha1 compute SHA1 cryptographic hash
--sha256 compute SHA256 cryptographic hash --sha256 compute SHA256 cryptographic hash
--sha512 compute SHA512 cryptographic hash --sha512 compute SHA512 cryptographic hash
--bench=<topic> use benchmarking format for output
""", file=w) """, file=w)
def main(): def main():
try: try:
optv, argv = getopt(sys.argv[1:], "h", ["help"] + hashRegistry.keys()) optv, argv = getopt(sys.argv[1:], "h", ["help", "bench="] + hashRegistry.keys())
except GetoptError as e: except GetoptError as e:
print("E: %s" % e, file=sys.stderr) print("E: %s" % e, file=sys.stderr)
usage(sys.stderr) usage(sys.stderr)
exit(1) exit(1)
for opt, _ in optv: bench=None
for opt, arg in optv:
if opt in ("-h", "--help"): if opt in ("-h", "--help"):
print(__doc__) print(__doc__)
usage(sys.stdout) usage(sys.stdout)
sys.exit() sys.exit()
if opt in ("--bench"):
bench=arg
continue
opt = opt.lstrip("-") opt = opt.lstrip("-")
hctor = hashRegistry[opt] hctor = hashRegistry[opt]
h = hctor() h = hctor()
...@@ -142,9 +149,14 @@ def main(): ...@@ -142,9 +149,14 @@ def main():
tend = time() tend = time()
dt = tend - tstart dt = tend - tstart
print('%s:%s ; oid=0..%d nread=%d t=%.3fs (%.1fμs / object) x=zhash.py' % \ x = "zhash.py"
(h.name, h.hexdigest(), oid-1, nread, dt, dt * 1E6 / oid)) if bench is None:
print('%s:%s ; oid=0..%d nread=%d t=%.3fs (%.1fμs / object) x=%s' % \
(h.name, h.hexdigest(), oid-1, nread, dt, dt * 1E6 / oid, x))
else:
topic = bench % x
print('Benchmark%s 1 %.1f µs/object\t# %s:%s oid=0..%d nread=%d t=%.3fs' % \
(topic, dt * 1E6 / oid, h.name, h.hexdigest(), oid-1, nread, dt))
if __name__ == '__main__': if __name__ == '__main__':
main() main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment