-
Notifications
You must be signed in to change notification settings - Fork 0
Benchmark updates #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Benchmark updates #293
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ae8040d
Run benchmarks on a real file system (and fix path to lmdb)
kriszyp da3dd93
Differentiate between essential benchmark tests that run on every PR …
kriszyp 48c4223
Default to essential mode
kriszyp b8c27d6
Add a realistic work load test and fix paths
kriszyp f51500a
More quietly skip groups with skipped tests
kriszyp 8bf45c8
Apply suggestion from @cb1kenobi
kriszyp 7a37be7
Update src/database.ts
kriszyp eda121f
Update benchmark/setup.ts
kriszyp 32f3d86
Restore compression with lmdb, code cleanup
kriszyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| benchmark-results.json | ||
| benchmark/data | ||
| build | ||
| /coverage | ||
| deps | ||
|
|
||
This file contains hidden or 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 @@ | ||
| This directory contains benchmark database files for RocksDB-JS. It is important to run benchmarks on a real filesystem (not a tempfs). These files should be deleted after benchmarking. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,73 @@ | ||
| import { | ||
| concurrent, | ||
| workerDescribe as describe, | ||
| workerBenchmark as benchmark, | ||
| type BenchmarkContext, | ||
| type LMDBDatabase | ||
| } from './setup.js'; | ||
| import type { RocksDatabase } from '../dist/index.mjs'; | ||
|
|
||
| const DELETE_RATIO = 0.2; | ||
| const NUM_KEYS = 5_000; | ||
| describe('Realistic write load with workers', () => { | ||
| const aaaa = Buffer.alloc(1500, 'a'); | ||
| const ITERATIONS = 100; | ||
| describe('write variable records with transaction log', () => { | ||
| benchmark('rocksdb', concurrent({ | ||
| mode: 'essential', | ||
| numWorkers: 4, | ||
| concurrencyMaximum: 32, | ||
| dbOptions: { disableWAL: true }, | ||
| setup(ctx: BenchmarkContext<RocksDatabase>) { | ||
| const db = ctx.db; | ||
| const log = db.useLog('0'); | ||
| ctx.log = log; | ||
| }, | ||
| async bench({ db, log }) { | ||
| for (let i = 0; i < ITERATIONS; i++) { | ||
| await db.transaction((txn) => { | ||
| const key = Math.floor(Math.random() * NUM_KEYS).toString(); | ||
| if (Math.random() < DELETE_RATIO) { | ||
| log.addEntry(aaaa.subarray(0, 30), txn.id); | ||
| db.removeSync(key, { transaction: txn }); | ||
| } else { | ||
| const data = aaaa.subarray(0, Math.random() * 1500); | ||
| log.addEntry(data, txn.id); | ||
| db.putSync(key, data, { transaction: txn }); | ||
| } | ||
| }).catch((error) => { | ||
| if (error.code !== 'ERR_BUSY') { | ||
| console.error('Error occurred during transaction:', error); | ||
| } | ||
| }) | ||
| }; | ||
| }, | ||
| })); | ||
|
|
||
| benchmark('lmdb', concurrent({ | ||
| mode: 'essential', | ||
| numWorkers: 4, | ||
| concurrencyMaximum: 32, | ||
| async setup(ctx: BenchmarkContext<LMDBDatabase>) { | ||
| let start = Date.now(); | ||
| ctx.index = start; | ||
| ctx.lastTime = Date.now(); | ||
| }, | ||
| async bench(ctx: BenchmarkContext<LMDBDatabase>) { | ||
| const { db } = ctx; | ||
| for (let i = 0; i < ITERATIONS; i++) { | ||
| let auditTime = ctx.lastTime = Math.max(ctx.lastTime + 0.001, Date.now()); | ||
| const key = Math.floor(Math.random() * NUM_KEYS).toString(); | ||
| if (Math.random() < DELETE_RATIO) { | ||
| db.put('audit' + auditTime, aaaa.subarray(0, 30)); | ||
| await db.remove(key); | ||
| } else { | ||
| const data = aaaa.subarray(0, Math.random() * 1500); | ||
| db.put('audit' + auditTime, data); | ||
| await db.put(key, data); | ||
| } | ||
| } | ||
| }, | ||
| })); | ||
| }); | ||
| }); |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.