From 0e95ef8e1015bef0dd117e3abb4bdb4331003e1c Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 19 Apr 2024 15:22:43 +0100 Subject: [PATCH] chore: update benchmark --- benchmarks/transfer/package.json | 25 ++++++++--------- benchmarks/transfer/src/README.md | 2 +- benchmarks/transfer/src/helia.ts | 6 ++-- benchmarks/transfer/src/index.ts | 4 --- benchmarks/transfer/src/ipfs.ts | 46 ------------------------------- benchmarks/transfer/src/kubo.ts | 29 ++++++------------- benchmarks/transfer/tsconfig.json | 8 ++---- 7 files changed, 26 insertions(+), 94 deletions(-) delete mode 100644 benchmarks/transfer/src/ipfs.ts diff --git a/benchmarks/transfer/package.json b/benchmarks/transfer/package.json index 73ba44978..45a0ad9f2 100644 --- a/benchmarks/transfer/package.json +++ b/benchmarks/transfer/package.json @@ -12,27 +12,26 @@ "start": "npm run build && node dist/src/index.js" }, "devDependencies": { - "@chainsafe/libp2p-noise": "^11.0.0", - "@chainsafe/libp2p-yamux": "^3.0.5", - "@helia/unixfs": "^1.2.1", + "@chainsafe/libp2p-noise": "^15.0.0", + "@chainsafe/libp2p-yamux": "^6.0.2", + "@helia/unixfs": "^3.0.3", "@ipld/dag-pb": "^4.0.2", - "@libp2p/websockets": "^5.0.3", - "aegir": "^38.1.5", + "@libp2p/websockets": "^8.0.19", + "aegir": "^42.2.5", "blockstore-fs": "^1.0.1", "datastore-level": "^10.0.1", - "execa": "^7.0.0", - "go-ipfs": "^0.19.0", - "helia": "^1.0.0", - "ipfs-core": "^0.18.0", + "execa": "^8.0.1", + "helia": "^4.1.0", "ipfs-unixfs-importer": "^15.1.1", - "ipfsd-ctl": "^13.0.0", + "ipfsd-ctl": "^14.0.0", "it-all": "^3.0.1", "it-buffer-stream": "^3.0.2", "it-drain": "^3.0.1", "it-map": "^3.0.2", - "kubo-rpc-client": "^3.0.1", - "libp2p": "^0.43.0", - "multiformats": "^11.0.1", + "kubo": "^0.28.0", + "kubo-rpc-client": "^4.0.0", + "libp2p": "^1.4.0", + "multiformats": "^13.1.0", "tinybench": "^2.4.0" }, "dependencies": { diff --git a/benchmarks/transfer/src/README.md b/benchmarks/transfer/src/README.md index 4c104b727..897f57cb2 100644 --- a/benchmarks/transfer/src/README.md +++ b/benchmarks/transfer/src/README.md @@ -1,6 +1,6 @@ # Transfer Benchmark -Benchmarks Helia transfer performance against js-ipfs and Kubo +Benchmarks Helia transfer performance against Kubo To run: diff --git a/benchmarks/transfer/src/helia.ts b/benchmarks/transfer/src/helia.ts index a8de4a2b1..ce5c04a65 100644 --- a/benchmarks/transfer/src/helia.ts +++ b/benchmarks/transfer/src/helia.ts @@ -2,8 +2,7 @@ import { createHelia } from 'helia' import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' import { noise } from '@chainsafe/libp2p-noise' -// import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' +import { yamux } from '@chainsafe/libp2p-yamux' import type { TransferBenchmark } from './index.js' import os from 'node:os' import path from 'node:path' @@ -33,8 +32,7 @@ export async function createHeliaBenchmark (): Promise { noise() ], streamMuxers: [ - mplex() - // yamux() + yamux() ] }) }) diff --git a/benchmarks/transfer/src/index.ts b/benchmarks/transfer/src/index.ts index 2a68963d2..558a0d272 100644 --- a/benchmarks/transfer/src/index.ts +++ b/benchmarks/transfer/src/index.ts @@ -2,7 +2,6 @@ import type { CID } from 'multiformats/cid' import { createHeliaBenchmark } from './helia.js' -import { createIpfsBenchmark } from './ipfs.js' import { createKuboBenchmark } from './kubo.js' import bufferStream from 'it-buffer-stream' import type { Multiaddr } from '@multiformats/multiaddr' @@ -75,9 +74,6 @@ for (const [name, options] of Object.entries(opts)) { const impls: Array<{ name: string, create: () => Promise }> = [{ name: 'helia', create: async () => await createHeliaBenchmark() -}, { - name: 'ipfs', - create: async () => await createIpfsBenchmark() }, { name: 'kubo', create: async () => await createKuboBenchmark() diff --git a/benchmarks/transfer/src/ipfs.ts b/benchmarks/transfer/src/ipfs.ts deleted file mode 100644 index 0a42dd149..000000000 --- a/benchmarks/transfer/src/ipfs.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { create } from 'ipfs-core' -import drain from 'it-drain' -import type { TransferBenchmark } from './index.js' -import os from 'node:os' -import path from 'node:path' - -export async function createIpfsBenchmark (): Promise { - const repoPath = path.join(os.tmpdir(), `ipfs-${Math.random()}`) - - const ipfs = await create({ - config: { - Addresses: { - Swarm: [ - '/ip4/127.0.0.1/tcp/0' - ] - } - }, - repo: repoPath, - init: { - emptyRepo: true - }, - silent: true - }) - - return { - async teardown () { - await ipfs.stop() - }, - async addr () { - const id = await ipfs.id() - - return id.addresses[0] - }, - async dial (ma) { - await ipfs.swarm.connect(ma) - }, - async add (content, options: any) { - const { cid } = await ipfs.add(content) - - return cid - }, - async get (cid) { - await drain(ipfs.cat(cid)) - } - } -} diff --git a/benchmarks/transfer/src/kubo.ts b/benchmarks/transfer/src/kubo.ts index b85d8d7a1..154baab43 100644 --- a/benchmarks/transfer/src/kubo.ts +++ b/benchmarks/transfer/src/kubo.ts @@ -1,28 +1,17 @@ import drain from 'it-drain' import type { TransferBenchmark } from './index.js' -// @ts-expect-error no types -import * as goIpfs from 'go-ipfs' -import * as goRpcClient from 'kubo-rpc-client' -import { createController } from 'ipfsd-ctl' +import { path as kuboPath } from 'kubo' +import { create as kuboRpcClient } from 'kubo-rpc-client' +import { createNode } from 'ipfsd-ctl' export async function createKuboBenchmark (): Promise { - const controller = await createController({ - type: 'go', + const controller = await createNode({ + type: 'kubo', test: true, - ipfsBin: goIpfs.path(), - ipfsHttpModule: goRpcClient, - ipfsOptions: { - init: { - emptyRepo: true - }, - config: { - Addresses: { - Swarm: [ - '/ip4/127.0.0.1/tcp/0' - ] - } - }, - silent: true + bin: kuboPath(), + rpc: kuboRpcClient, + init: { + emptyRepo: true } }) diff --git a/benchmarks/transfer/tsconfig.json b/benchmarks/transfer/tsconfig.json index a91603205..37d51de72 100644 --- a/benchmarks/transfer/tsconfig.json +++ b/benchmarks/transfer/tsconfig.json @@ -1,14 +1,10 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "dist", - "target": "ES2022", - "module": "ES2022", - "lib": ["ES2022", "DOM", "DOM.Iterable"] + "outDir": "dist" }, "include": [ - "src", - "test" + "src" ], "references": [ {