-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
message-store: add benchmarks for batched writes
- Loading branch information
Showing
6 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...store/memory/test/benchmark/results/write-batch-messages-2020-04-15T09-29-55.results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
4 changes: 4 additions & 0 deletions
4
message-store/memory/test/benchmark/write-batch-messages.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
40 changes: 40 additions & 0 deletions
40
...ore/postgres/test/benchmark/results/write-batch-messages-2020-04-15T09-19-45.results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
40 changes: 40 additions & 0 deletions
40
...ore/postgres/test/benchmark/results/write-single-message-2020-04-15T09-18-26.results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
4 changes: 4 additions & 0 deletions
4
message-store/postgres/test/benchmark/write-batch-messages.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
64
message-store/test/benchmark/write-batch-messages.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
} |