-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
14,829 additions
and
4 deletions.
There are no files selected for viewing
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,67 @@ | ||
import { randomBytes } from 'crypto'; | ||
|
||
const lmdb = await import('lmdb'); | ||
const { AztecLmdbStore } = await import('@aztec/kv-store'); | ||
const root = lmdb.open('/home/ubuntu/aztec-data/random'); | ||
const store = new AztecLmdbStore(root); | ||
const rawDB = root.openDB('raw', {}); | ||
const { createHistogram, performance } = await import('perf_hooks'); | ||
|
||
const array = store.createArray('array'); | ||
const map = store.createMap('map'); | ||
const collection = store.createCollection('collection', {}); | ||
|
||
const [arrayHistogram, mapHistogram, collectionHistogram, rawHistogram] = await Promise.all([ | ||
benchmark('array', 1000, x => array.push(x)), | ||
benchmark('map', 1000, x => map.set(x, x)), | ||
benchmark('collection', 1000, x => collection.insert(x)), | ||
benchmark('raw', 1000, x => rawDB.put(x, x)), | ||
]); | ||
|
||
console.log('Benchmark: array'); | ||
console.group(); | ||
printHistogram(arrayHistogram); | ||
console.groupEnd(); | ||
|
||
console.log('Benchmark: map'); | ||
console.group(); | ||
printHistogram(mapHistogram); | ||
console.groupEnd(); | ||
|
||
console.log('Benchmark: collection'); | ||
console.group(); | ||
printHistogram(collectionHistogram); | ||
console.groupEnd(); | ||
|
||
console.log('Benchmark: raw'); | ||
console.group(); | ||
printHistogram(rawHistogram); | ||
console.groupEnd(); | ||
|
||
async function benchmark(name, runs, fn) { | ||
const histogram = createHistogram(); | ||
const instrumented = performance.timerify(fn, { histogram }); | ||
|
||
for (let i = 0; i < runs; i++) { | ||
const x = randomBytes(32); | ||
await instrumented(x); | ||
} | ||
|
||
return histogram; | ||
} | ||
|
||
function nsToMs(ns) { | ||
return ns / 1e6; | ||
} | ||
|
||
function printHistogram(histogram) { | ||
console.log(`\ | ||
${nsToMs(histogram.min)}ms min | ||
${nsToMs(histogram.max)}ms max | ||
${nsToMs(histogram.percentile(0.5))}ms median | ||
${nsToMs(histogram.percentile(0.75))}ms 75th percentile | ||
${nsToMs(histogram.percentile(0.9))}ms 90th percentile | ||
${nsToMs(histogram.percentile(0.99))}ms 99th percentile | ||
${nsToMs(histogram.percentile(0.9999))}ms 99.99th percentile\ | ||
`); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
export DEBUG=aztec:* | ||
export DATA_DIRECTORY="$HOME/aztec-data" | ||
|
||
export ROLLUP_CONTRACT_ADDRESS=0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9 | ||
export REGISTRY_CONTRACT_ADDRESS=0x5fbdb2315678afecb367f032d93f642f64180aa3 | ||
export INBOX_CONTRACT_ADDRESS=0xe7f1725e7734ce288f8367e1bb143e90bb3f0512 | ||
export CONTRACT_DEPLOYMENT_EMITTER_ADDRESS=0x5fc8d32690cc91d4c39d9d3abcbd16989f875707 | ||
|
||
export TEST_ACCOUNTS=false | ||
export DEPLOY_AZTEC_CONTRACTS=false | ||
|
||
export ME=0x06357cc85cb8fc561adbf741f63cd75efa26ffba1c80d431ec77d036d8edf022 | ||
export PARTIAL_ADDRESS=0x23475465106cc4ee212154ddad52658014ff02442196c340960abfdee1b5424a | ||
export PRIVATE_KEY=0x2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281 | ||
export PUBLIC_KEY=0x27c20118733174347b8082f578a7d8fb84b3ad38be293715eee8119ee5cd8a6d0d6b7d8124b37359663e75bcd2756f544a93b821a06f8e33fba68cc8029794d9 | ||
|
||
export CONTRACT=EasyPrivateTokenContractArtifact | ||
export CONTRACT_ADDRESS=0x2b3a0adc1037c457e3a5bb17d3fe2f22814c5771f593fc923941c5577bd13ddc | ||
export CONTRACT_PARTIAL_ADDRESS=0x0c0a534faca34253a694f325ac98f9234dbb6173347e7d09e112754653ef5bc6 | ||
|
||
yarn workspace @aztec/aztec-sandbox start | ||
exit 0 |
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,24 @@ | ||
const lmdb = await import('lmdb'); | ||
const { AztecLmdbStore } = await import('@aztec/kv-store'); | ||
const { KVPxeDatabase } = await import('./pxe/dest/database/kv_pxe_database.js'); | ||
const { AztecAddress, BlockHeader, CompleteAddress } = await import('@aztec/circuits.js'); | ||
const { Fr, Point } = await import('@aztec/foundation/fields'); | ||
const root = lmdb.open('/home/ubuntu/aztec-data/pxe_data'); | ||
const data = root.openDB('data', {}); | ||
const noteIndexes = root.openDB('data_dup_sort', {}); | ||
const store = new AztecLmdbStore(root); | ||
|
||
const addresses = store.createMap('addresses'); | ||
const authWitnesses = store.createMap('authWitnesses'); | ||
const capsules = store.createArray('capsules'); | ||
const blockHeader = store.createSingleton('block_header'); | ||
const contracts = store.createMap('contracts'); | ||
const notes = store.createArray('notes'); | ||
const nullifiedNotes = store.createMap('nullified_notes'); | ||
|
||
const notesByContract = store.createMultiMap('notes_by_contract'); | ||
const notesByStorageSlot = store.createMultiMap('notes_by_storage_slot'); | ||
const notesByTxHash = store.createMultiMap('notes_by_tx_hash'); | ||
const notesByOwner = store.createMultiMap('notes_by_owner'); | ||
|
||
const pxeDB = new KVPxeDatabase(store); |
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
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,19 @@ | ||
const lmdb = await import('lmdb'); | ||
const root = lmdb.open({}); | ||
const map = prefix => ({ | ||
set: (k, v) => root.put([prefix, k], v), | ||
get: (k, v) => root.get([prefix, k], v), | ||
}); | ||
|
||
const foo = map('foo'); | ||
const bar = map('bar'); | ||
|
||
foo.set('a', 'foo: a'); | ||
foo.set('b', 'foo: b'); | ||
foo.set('e', 'foo: e'); | ||
foo.set('c', 'foo: c'); | ||
|
||
bar.set('a', 'bar: a'); | ||
bar.set('b', 'bar: b'); | ||
bar.set('e', 'bar: e'); | ||
bar.set('c', 'bar: c'); |