Skip to content

Commit

Permalink
message-store: add benchmarks for batched writes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpareja committed Apr 15, 2020
1 parent 3f7c2aa commit 28afdff
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"date": "2020-04-15T09:29:55.895Z",
"count": 100,
"durationMicroSeconds": 809108.459,
"averageOverheadMicroSeconds": 8091.085,
"operationsPerSecond": 123.593,
"cpu": {
"manufacturer": "Intel®",
"brand": "Xeon® E3-1225 v3",
"vendor": "GenuineIntel",
"family": "6",
"model": "60",
"stepping": "3",
"revision": "",
"voltage": "",
"speed": "3.20",
"speedmin": "0.80",
"speedmax": "3.20",
"governor": "powersave",
"cores": 8,
"physicalCores": 4,
"processors": 1,
"socket": "",
"cache": {
"l1d": 32768,
"l1i": 32768,
"l2": 262144,
"l3": 8388608
}
},
"os": {
"platform": "linux",
"distro": "Ubuntu",
"release": "18.04.4 LTS",
"kernel": "4.15.0-91-generic",
"arch": "x64",
"servicepack": ""
},
"node": "v12.16.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { benchmark } = require('../../../test/benchmark/write-batch-messages.benchmark')
const { initializeStore } = require('./init')

benchmark(initializeStore, __filename)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"date": "2020-04-15T09:19:45.580Z",
"count": 100,
"durationMicroSeconds": 30243477.453,
"averageOverheadMicroSeconds": 302434.775,
"operationsPerSecond": 3.306,
"cpu": {
"manufacturer": "Intel®",
"brand": "Xeon® E3-1225 v3",
"vendor": "GenuineIntel",
"family": "6",
"model": "60",
"stepping": "3",
"revision": "",
"voltage": "",
"speed": "3.20",
"speedmin": "0.80",
"speedmax": "3.20",
"governor": "powersave",
"cores": 8,
"physicalCores": 4,
"processors": 1,
"socket": "",
"cache": {
"l1d": 32768,
"l1i": 32768,
"l2": 262144,
"l3": 8388608
}
},
"os": {
"platform": "linux",
"distro": "Ubuntu",
"release": "18.04.4 LTS",
"kernel": "4.15.0-91-generic",
"arch": "x64",
"servicepack": ""
},
"node": "v12.16.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"date": "2020-04-15T09:18:26.398Z",
"count": 100000,
"durationMicroSeconds": 45795434.475,
"averageOverheadMicroSeconds": 457.954,
"operationsPerSecond": 2183.624,
"cpu": {
"manufacturer": "Intel®",
"brand": "Xeon® E3-1225 v3",
"vendor": "GenuineIntel",
"family": "6",
"model": "60",
"stepping": "3",
"revision": "",
"voltage": "",
"speed": "3.20",
"speedmin": "0.80",
"speedmax": "3.20",
"governor": "powersave",
"cores": 8,
"physicalCores": 4,
"processors": 1,
"socket": "",
"cache": {
"l1d": 32768,
"l1i": 32768,
"l2": 262144,
"l3": 8388608
}
},
"os": {
"platform": "linux",
"distro": "Ubuntu",
"release": "18.04.4 LTS",
"kernel": "4.15.0-91-generic",
"arch": "x64",
"servicepack": ""
},
"node": "v12.16.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { benchmark } = require('../../../test/benchmark/write-batch-messages.benchmark')
const { initializeStore } = require('./init')

benchmark(initializeStore, __filename)
64 changes: 64 additions & 0 deletions message-store/test/benchmark/write-batch-messages.benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const { computeStats, writeStatsFile } = require('../../../benchmark')
const { exampleStreamName, exampleWriteMessageData } = require('../../')

const cycles = process.env.CYCLES || 100
const batchSize = process.env.BATCH_SIZE || 1000
const warmup = 2

exports.benchmark = async (createMessageStore, benchmarkSource) => {
console.log('Parameters:')
console.log(` CYCLES: ${cycles}`)
console.log(` BATCH_SIZE: ${batchSize}`)
console.log()

const { messageStore, teardown } = createMessageStore()

const batches = generateBatches(cycles, batchSize, warmup)

console.log(`done preparing ${cycles} batches of ${batchSize} messages`)

const { start, end } = await write(messageStore, batches)

const stats = await computeStats(cycles, start, end)

console.log('Statistics:', stats)

await writeStatsFile(benchmarkSource, stats)

await teardown()
}

function generateBatches (cycles, batchSize, warmup) {
const batches = []

for (let i = 0; i < cycles + warmup; i++) {
const streamName = exampleStreamName()
const messages = []
batches.push({ streamName, messages })

for (let j = 0; j < batchSize; j++) {
const messageData = exampleWriteMessageData()

messages.push(messageData)
}
}

return batches
}

async function write (messageStore, batches) {
// warmup
for (const { messages, streamName } of batches.slice(0, warmup)) {
await messageStore.write(messages, streamName)
}

const start = process.hrtime.bigint()

for (const { messages, streamName } of batches.slice(warmup)) {
await messageStore.write(messages, streamName)
}

const end = process.hrtime.bigint()

return { start, end }
}

0 comments on commit 28afdff

Please sign in to comment.