[Pkg-javascript-commits] [node-leveldown] 360/492: added new db-bench scripts

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 7d95fca9cd74b4cc3b5ed3dce71664e7b010d433
Author: Rod Vagg <rod at vagg.org>
Date:   Wed Jun 19 12:07:14 2013 +1000

    added new db-bench scripts
---
 bench/db-bench-plot.sh |  49 +++++++++++++++++++
 bench/db-bench.js      | 124 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 173 insertions(+)

diff --git a/bench/db-bench-plot.sh b/bench/db-bench-plot.sh
new file mode 100755
index 0000000..734d47a
--- /dev/null
+++ b/bench/db-bench-plot.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+gnuplot <<EOF
+  reset
+  set terminal pngcairo truecolor enhanced font "Ubuntu Mono,13" size 1920, 1080
+  set output "/tmp/random-writes.png"
+  set datafile separator ','
+
+  set logscale y
+  set nologscale y2
+  unset log y2
+  set autoscale y
+  set autoscale y2
+  set ytics nomirror
+  set y2tics
+  set tics out
+
+  set xlabel "Minutes" tc rgb "#777777"
+  set ylabel "Milliseconds per write" tc rgb "#777777"
+  set y2label "Throughput MB/s" tc rgb "#777777"
+
+  set title "Node.js LevelDB (LevelDOWN): 100,000,000 random writes, 64M write buffer, HDD RAID1" tc rgb "#777777"
+  set key left tc rgb "#777777"
+  set border lc rgb "#777777"
+
+  set style line 1 lt 7 ps 1.2 lc rgb "#55019FD7"
+  set style line 2 lt 7 ps 0.1 lc rgb "#55019FD7"
+  set style line 3 lt 1 lw 2   lc rgb "#55019FD7"
+
+  set style line 4 lt 7 ps 1.2 lc rgb "#559ECC3C"
+  set style line 5 lt 7 ps 0.1 lc rgb "#559ECC3C"
+  set style line 6 lt 1 lw 2   lc rgb "#559ECC3C"
+
+  set style line 7 lt 7 ps 1.2 lc rgb "#55CC3C3C"
+  set style line 8 lt 7 ps 0.1 lc rgb "#55CC3C3C"
+  set style line 9 lt 1 lw 2   lc rgb "#55CC3C3C"
+
+  plot \
+      1/0 with points title "Google LevelDB" ls 1 \
+    , 1/0 with points title "Hyper LevelDB"  ls 4 \
+    , 1/0 with points title "Basho LevelDB"  ls 7 \
+    , "/tmp/rndbench_timing_google.csv" using (\$1/1000/60):(\$4/1000000) notitle         ls 2 axes x1y1 \
+    , "/tmp/rndbench_timing_hyper.csv"  using (\$1/1000/60):(\$4/1000000) notitle         ls 5 axes x1y1 \
+    , "/tmp/rndbench_timing_basho.csv"  using (\$1/1000/60):(\$4/1000000) notitle         ls 8 axes x1y1 \
+    , "/tmp/rndbench_timing_google.csv" using (\$1/1000/60):(\$5)         w lines notitle ls 3 axes x1y2 \
+    , "/tmp/rndbench_timing_hyper.csv"  using (\$1/1000/60):(\$5)         w lines notitle ls 6 axes x1y2 \
+    , "/tmp/rndbench_timing_basho.csv"  using (\$1/1000/60):(\$5)         w lines notitle ls 9 axes x1y2 \
+
+EOF
diff --git a/bench/db-bench.js b/bench/db-bench.js
new file mode 100755
index 0000000..0f46f5f
--- /dev/null
+++ b/bench/db-bench.js
@@ -0,0 +1,124 @@
+#!/usr/bin/env node
+
+const leveldown = require('../')
+    , fs        = require('fs')
+    , du        = require('du')
+    , rimraf    = require('rimraf')
+
+    , argv      = require('optimist').argv
+
+    , options   = {
+          benchmark        : argv.benchmark
+        , useExisting      : argv.use_existing
+        , db               : argv.db
+        , num              : argv.num             || 1000000
+        , concurrency      : argv.concurrency     || 4
+        , cacheSize        : argv.cacheSize       || 8
+        , writeBufferSize  : argv.writeBufferSize || 4
+        , valueSize        : argv.valueSize       || 100
+        , timingOutput     : argv.timingOutput
+        , throughputOutput : argv.throughputOutput
+      }
+
+    , randomData = require('./random-data')()
+    , keyTmpl = '0000000000000000'
+
+if (!options.useExisting) {
+  leveldown.destroy(options.db, function () {})
+}
+
+var db          = leveldown(options.db, {
+        errorIfExists   : false
+      , createIfMissing : true
+      , cacheSize       : options.cacheSize << 20
+      , writeBufferSize : options.writeBufferSize << 20
+    })
+  , timesStream = options.timingOutput
+        && fs.createWriteStream(options.timingOutput, 'utf8')
+//  , throughputStream = options.throughputOutput
+//        && fs.createWriteStream(options.throughputOutput, 'utf8')
+
+// make a 16 char padded key
+function makeKey () {
+  var r = Math.floor(Math.random() * options.num)
+    , k = keyTmpl + r
+  return k.substr(k.length - 16)
+}
+
+timesStream.write('Elapsed (ms), Entries, Bytes, Last 1000 Avg Time, MB/s\n')
+
+setTimeout(function () { db.open(function (err) {
+  if (err)
+    throw err
+
+  var inProgress  = 0
+    , totalWrites = 0
+    , totalBytes  = 0
+    , startTime   = Date.now()
+    , timesAccum  = 0
+    , writeBuf    = ''
+    , elapsed
+
+  function report () {
+    console.log(
+        'Wrote'
+      , options.num
+      , 'entries in'
+      , Math.floor((Date.now() - startTime) / 1000) + 's,'
+      , (Math.floor((totalBytes / 1048576) * 100) / 100) + 'MB'
+    )
+    timesStream.end()
+
+    du(options.db, function (err, size) {
+      if (err)
+        throw err
+      console.log('Database size:', Math.floor(size / 1024 / 1024) + 'M')
+    })
+  }
+
+
+  function write () {
+    if (totalWrites++ == options.num) {
+      db.close(function () {
+        report(Date.now() - startTime)
+      })
+    }
+    if (inProgress >= options.concurrency || totalWrites > options.num)
+      return
+
+    inProgress++
+
+    if (totalWrites % 100000 === 0)
+      console.log('' + inProgress, totalWrites, Math.round(totalWrites / options.num * 100) + '%')
+
+    if (totalWrites % 1000 === 0) {
+      elapsed = Date.now() - startTime
+      timesStream.write(
+                elapsed
+        + ',' + totalWrites
+        + ',' + totalBytes
+        + ',' + Math.floor(timesAccum / 1000)
+        + ',' + (Math.floor(((totalBytes / 1048576) / (elapsed / 1000)) * 100) / 100)
+        + '\n')
+      timesAccum = 0
+      //timesStream.write(writeBuf)
+      //writeBuf = ''
+    }
+
+    var time = process.hrtime()
+
+    db.put(makeKey(), randomData.generate(options.valueSize), function (err) {
+      if (err)
+        throw err
+
+      totalBytes += keyTmpl.length + options.valueSize
+      timesAccum += process.hrtime(time)[1]
+      //writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n'
+      inProgress--
+      process.nextTick(write)
+    })
+  }
+
+  for (var i = 0; i < options.concurrency; i++)
+    write()
+})}, 500)
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list