-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split a new benchmark out of the gc one that just focusses on pinning performance.
- Loading branch information
1 parent
9de08ef
commit 8805202
Showing
20 changed files
with
473 additions
and
122 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
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
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
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,45 @@ | ||
# Pinning Benchmark | ||
|
||
Benchmarks Helia pinning performance against Kubo | ||
|
||
- Removes any existing pins | ||
- Creates 10000 DAGs with two nodes linked to by a root node that is pinned | ||
|
||
All three implementations use on-disk block/datastores to ensure a reasonable basis for comparison. | ||
|
||
Warning! It can take a long time with realistic pinset sizes - on the order of a whole day. | ||
|
||
To run: | ||
|
||
1. Add `benchmarks/*` to the `workspaces` entry in the root `package.json` of this repo | ||
2. Run | ||
```console | ||
$ npm run reset | ||
$ npm i | ||
$ npm run build | ||
$ cd benchmarks/pinning | ||
$ npm start | ||
|
||
> [email protected] start | ||
> npm run build && node dist/src/index.js | ||
|
||
|
||
> [email protected] build | ||
> aegir build --bundle false | ||
|
||
[14:51:28] tsc [started] | ||
[14:51:33] tsc [completed] | ||
generating Ed25519 keypair... | ||
┌─────────┬────────────────┬─────────┬───────────┬──────┐ | ||
│ (index) │ Implementation │ ops/s │ ms/op │ runs │ | ||
├─────────┼────────────────┼─────────┼───────────┼──────┤ | ||
//... results here | ||
``` | ||
|
||
## Graph | ||
|
||
To output stats for a graph run: | ||
|
||
```console | ||
$ npm run build && node dist/src/graph.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,29 @@ | ||
{ | ||
"name": "benchmarks-pinning", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "aegir clean", | ||
"build": "aegir build --bundle false", | ||
"lint": "aegir lint", | ||
"dep-check": "aegir dep-check", | ||
"start": "npm run build && node dist/src/index.js" | ||
}, | ||
"dependencies": { | ||
"@ipld/dag-pb": "^4.0.6", | ||
"aegir": "^44.0.1", | ||
"blockstore-fs": "^2.0.1", | ||
"datastore-level": "^11.0.1", | ||
"execa": "^8.0.1", | ||
"helia": "^4.1.1", | ||
"ipfsd-ctl": "^15.0.0", | ||
"it-all": "^3.0.4", | ||
"it-drain": "^3.0.5", | ||
"it-map": "^3.0.5", | ||
"kubo": "^0.30.0", | ||
"kubo-rpc-client": "^5.0.0", | ||
"multiformats": "^13.0.0", | ||
"tinybench": "^2.5.1" | ||
}, | ||
"private": true | ||
} |
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,18 @@ | ||
import { execa } from 'execa' | ||
|
||
const ITERATIONS = 2 | ||
const INCREMENT = 1000 | ||
const MAX = 10000 | ||
|
||
for (let i = 1; i <= MAX / INCREMENT; i++) { | ||
await execa('node', ['dist/src/index.js'], { | ||
env: { | ||
...process.env, | ||
INCREMENT: (i * INCREMENT).toString(), | ||
ITERATIONS: ITERATIONS.toString(), | ||
ITERATION: i.toString() | ||
}, | ||
stdout: 'inherit', | ||
stderr: 'inherit' | ||
}) | ||
} |
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,51 @@ | ||
import os from 'node:os' | ||
import path from 'node:path' | ||
import { FsBlockstore } from 'blockstore-fs' | ||
import { LevelDatastore } from 'datastore-level' | ||
import { createHelia } from 'helia' | ||
import all from 'it-all' | ||
import drain from 'it-drain' | ||
import map from 'it-map' | ||
import type { GcBenchmark } from './index.js' | ||
|
||
export async function createHeliaBenchmark (): Promise<GcBenchmark> { | ||
const repoPath = path.join(os.tmpdir(), `helia-${Math.random()}`) | ||
|
||
const helia = await createHelia({ | ||
blockstore: new FsBlockstore(`${repoPath}/blocks`), | ||
datastore: new LevelDatastore(`${repoPath}/data`), | ||
libp2p: { | ||
addresses: { | ||
listen: [] | ||
} | ||
}, | ||
start: false | ||
}) | ||
|
||
return { | ||
async putBlocks (blocks) { | ||
await drain(helia.blockstore.putMany(map(blocks, ({ key, value }) => ({ cid: key, block: value })))) | ||
}, | ||
async pin (cid) { | ||
await drain(helia.pins.add(cid)) | ||
}, | ||
async teardown () { | ||
await helia.stop() | ||
}, | ||
async clearPins () { | ||
const pins = await all(helia.pins.ls()) | ||
|
||
for (const pin of pins) { | ||
await drain(helia.pins.rm(pin.cid)) | ||
} | ||
|
||
return pins.length | ||
}, | ||
isPinned: async (cid) => { | ||
return helia.pins.isPinned(cid) | ||
}, | ||
hasBlock: async (cid) => { | ||
return helia.blockstore.has(cid) | ||
} | ||
} | ||
} |
Oops, something went wrong.