Skip to content

Conversation

@achingbrain
Copy link
Member

@achingbrain achingbrain commented Jun 30, 2023

  • Use globSource from ipfs-utils for import
  • Make all impls return the same CID
  • Remove the dir size - it isn't reported reliably and if the CID is the same that's good enough

- Use `globSource` from ipfs-utils for import
- Make all impls return the same CID
- Remove the dir size - if the CID is the same that's good enough
@achingbrain achingbrain requested a review from a team as a code owner June 30, 2023 14:38
@achingbrain
Copy link
Member Author

Before:

┌─────────┬───────────────────────────┬──────────┬──────────┬──────┬───────────┬───────────────────────────────────────────────────────────────┬───────────┐
│ (index) │      Implementation       │  ops/s   │  ms/op   │ runs │    p99    │                              CID                              │   Bytes   │
├─────────┼───────────────────────────┼──────────┼──────────┼──────┼───────────┼───────────────────────────────────────────────────────────────┼───────────┤
│    0    │     'helia-fs - src'      │ '24.94'  │ '40.09'  │  5   │ '124.25'  │ 'bafybeiad52e2vdpkobvhoilllwofgbmd675zg25hcnnyc5bzazvbbrkieu' │  '32161'  │
│    1    │     'helia-fs - dist'     │ '15.87'  │ '63.02'  │  5   │ '237.21'  │ 'bafybeibpgjqy7gedqxctd4rfn7p5dx3ue7vsmlitqgp32jmm24tqcihzfm' │ '138013'  │
│    2    │  'helia-fs - ../gc/src'   │ '39.41'  │ '25.37'  │  5   │  '89.30'  │ 'bafybeihhyvzl4zqbvvtafd6cnp37gwvrypn2cxpyr2yj5zppvgk3urxgpm' │  '12580'  │
│    3    │     'helia-mem - src'     │ '132.35' │  '7.56'  │  5   │  '21.40'  │ 'bafybeiad52e2vdpkobvhoilllwofgbmd675zg25hcnnyc5bzazvbbrkieu' │  '32161'  │
│    4    │    'helia-mem - dist'     │ '51.95'  │ '19.25'  │  5   │  '22.80'  │ 'bafybeibpgjqy7gedqxctd4rfn7p5dx3ue7vsmlitqgp32jmm24tqcihzfm' │ '138013'  │
│    5    │  'helia-mem - ../gc/src'  │ '184.21' │  '5.43'  │  5   │  '9.85'   │ 'bafybeihhyvzl4zqbvvtafd6cnp37gwvrypn2cxpyr2yj5zppvgk3urxgpm' │  '12580'  │
│    6    │       'ipfs - src'        │  '9.20'  │ '108.71' │  5   │ '174.55'  │ 'bafybeicfu74e24r3pynrbqzata2apjmq74oquutiytz2qaqlhi7j3sw6fq' │ undefined │
│    7    │       'ipfs - dist'       │  '2.06'  │ '484.63' │  5   │ '534.13'  │ 'bafybeihncwpyw3qurs5x2uq4o3og3wdztxm73hwcsbyswqrfqk5ncu2ypm' │ undefined │
│    8    │    'ipfs - ../gc/src'     │  '4.70'  │ '212.94' │  5   │ '238.50'  │ 'bafybeibdpig6o56rjems2twzgvog7ssatt5szrpnjgvtnws4i4bm5csvoa' │ undefined │
│    9    │       'kubo - src'        │  '7.60'  │ '131.49' │  5   │ '344.61'  │ 'bafybeicfu74e24r3pynrbqzata2apjmq74oquutiytz2qaqlhi7j3sw6fq' │ undefined │
│   10    │       'kubo - dist'       │  '1.91'  │ '522.20' │  5   │ '1629.82' │ 'bafybeihncwpyw3qurs5x2uq4o3og3wdztxm73hwcsbyswqrfqk5ncu2ypm' │ undefined │
│   11    │    'kubo - ../gc/src'     │  '5.71'  │ '175.03' │  5   │ '534.92'  │ 'bafybeifqlusi6zeboi7mxdbbjr5y5pdojrohhtelm4rbhb2vfkfa6f2kfu' │ undefined │
│   12    │    'kubo-direct - src'    │  '7.06'  │ '141.57' │  5   │ '408.93'  │ 'bafybeicfu74e24r3pynrbqzata2apjmq74oquutiytz2qaqlhi7j3sw6fq' │ undefined │
│   13    │   'kubo-direct - dist'    │  '2.34'  │ '427.24' │  5   │ '1259.02' │ 'bafybeihncwpyw3qurs5x2uq4o3og3wdztxm73hwcsbyswqrfqk5ncu2ypm' │ undefined │
│   14    │ 'kubo-direct - ../gc/src' │  '8.39'  │ '119.13' │  5   │ '354.43'  │ 'bafybeifqlusi6zeboi7mxdbbjr5y5pdojrohhtelm4rbhb2vfkfa6f2kfu' │ undefined │
└─────────┴───────────────────────────┴──────────┴──────────┴──────┴───────────┴───────────────────────────────────────────────────────────────┴───────────┘

After:

┌─────────┬───────────────────────────┬──────────┬──────────┬──────┬──────────┬──────────────────────────────────────────────────┐
│ (index) │      Implementation       │  ops/s   │  ms/op   │ runs │   p99    │                       CID                        │
├─────────┼───────────────────────────┼──────────┼──────────┼──────┼──────────┼──────────────────────────────────────────────────┤
│    0    │     'helia-fs - src'      │ '28.77'  │ '34.76'  │  5   │ '82.40'  │ 'QmVju5VDLH3wdZ3xpErsVETDZyGe5EyJw9fTzanCmdGbPK' │
│    1    │     'helia-fs - dist'     │ '27.07'  │ '36.94'  │  5   │ '140.58' │ 'QmTULGf34gVa6qvrskkEoiqYH7mdt2FVwLXasnJWtRr76b' │
│    2    │  'helia-fs - ../gc/src'   │ '36.24'  │ '27.59'  │  5   │ '61.38'  │ 'QmT6yBNFyP3J5AsmRChfJ46iLUCV2Gj38q5ZgqAsg3SPGm' │
│    3    │     'helia-mem - src'     │ '159.66' │  '6.26'  │  5   │ '16.61'  │ 'QmVju5VDLH3wdZ3xpErsVETDZyGe5EyJw9fTzanCmdGbPK' │
│    4    │    'helia-mem - dist'     │ '88.17'  │ '11.34'  │  5   │ '14.54'  │ 'QmTULGf34gVa6qvrskkEoiqYH7mdt2FVwLXasnJWtRr76b' │
│    5    │  'helia-mem - ../gc/src'  │ '77.05'  │ '12.98'  │  5   │ '16.65'  │ 'QmT6yBNFyP3J5AsmRChfJ46iLUCV2Gj38q5ZgqAsg3SPGm' │
│    6    │       'ipfs - src'        │ '18.62'  │ '53.70'  │  5   │ '99.85'  │ 'QmVju5VDLH3wdZ3xpErsVETDZyGe5EyJw9fTzanCmdGbPK' │
│    7    │       'ipfs - dist'       │  '8.01'  │ '124.89' │  5   │ '145.46' │ 'QmTULGf34gVa6qvrskkEoiqYH7mdt2FVwLXasnJWtRr76b' │
│    8    │    'ipfs - ../gc/src'     │ '22.33'  │ '44.79'  │  5   │ '52.18'  │ 'QmT6yBNFyP3J5AsmRChfJ46iLUCV2Gj38q5ZgqAsg3SPGm' │
│    9    │       'kubo - src'        │ '19.23'  │ '52.00'  │  5   │ '181.88' │ 'QmVju5VDLH3wdZ3xpErsVETDZyGe5EyJw9fTzanCmdGbPK' │
│   10    │       'kubo - dist'       │  '7.01'  │ '142.56' │  5   │ '612.64' │ 'QmTULGf34gVa6qvrskkEoiqYH7mdt2FVwLXasnJWtRr76b' │
│   11    │    'kubo - ../gc/src'     │ '17.34'  │ '57.68'  │  5   │ '230.00' │ 'QmT6yBNFyP3J5AsmRChfJ46iLUCV2Gj38q5ZgqAsg3SPGm' │
│   12    │    'kubo-direct - src'    │ '18.06'  │ '55.36'  │  5   │ '200.21' │ 'QmVju5VDLH3wdZ3xpErsVETDZyGe5EyJw9fTzanCmdGbPK' │
│   13    │   'kubo-direct - dist'    │  '9.47'  │ '105.59' │  5   │ '418.69' │ 'QmTULGf34gVa6qvrskkEoiqYH7mdt2FVwLXasnJWtRr76b' │
│   14    │ 'kubo-direct - ../gc/src' │ '20.40'  │ '49.01'  │  5   │ '185.31' │ 'QmT6yBNFyP3J5AsmRChfJ46iLUCV2Gj38q5ZgqAsg3SPGm' │
└─────────┴───────────────────────────┴──────────┴──────────┴──────┴──────────┴──────────────────────────────────────────────────┘

@achingbrain achingbrain changed the title test: create add-dir benchmark test: use globSource in add-dir benchmark Jun 30, 2023
@achingbrain
Copy link
Member Author

achingbrain commented Jun 30, 2023

The kubo-direct benchmarks are wildly different which is not something I expected to see. I'm not 100% convinced by tinybench, I think the test cases interfere with each other. That is, I've got different results in benchmarks by running them in a different order 🙃

Copy link
Contributor

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, good improvements! minor nits!

nodePath.relative(process.cwd(), nodePath.join(process.cwd(), '..', 'gc', 'src')),
]
const testPaths = TEST_PATH != null
? [TEST_PATH]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I like this.

})

const addFile = async (path: string) => (await controller.api.add({ path: nodePath.relative(process.cwd(), path), content: fs.createReadStream(path)}, { cidVersion: 1, pin: false })).cid
const addFile = async (path: string): Promise<CID> => (await controller.api.add({ path: nodePath.relative(process.cwd(), path), content: fs.createReadStream(path) }, { cidVersion: 1, pin: false })).cid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we split this in a meaningful way to make this more readable?

Copy link
Member Author

@achingbrain achingbrain Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean, it's as readable as it was before, the only change on this line is an automated linting fix.

That said, having it as a one-liner isn't very readable so I do agree it can be improved - can you suggest an edit instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though maybe in #167 - it's probably out of scope here.

@SgtPooki
Copy link
Member

SgtPooki commented Jul 6, 2023

The kubo-direct benchmarks are wildly different which is not something I expected to see. I'm not 100% convinced by tinybench, I think the test cases interfere with each other. That is, I've got different results in benchmarks by running them in a different order 🙃

We could probably remove kubo-direct, and we should probably use a more reliable benchmark framework (or restructure these benchmarks to be more reliable) if we're pointing people to these.

@SgtPooki SgtPooki self-requested a review July 6, 2023 17:05
addFile,
addDir,
// TODO: Fix timing out during size calculation.
// getSize: getFolderSize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention behind the size was to confirm all expected files/folders were read during the benchmark tests.

If we get the same CID from all implementations, we could cat one of them to confirm it's what we expect.

I think we should have some sort of validation but maybe we can handle that when we handle #170

@SgtPooki SgtPooki merged commit f1d4845 into benchmark/add-dir Jul 6, 2023
@SgtPooki SgtPooki deleted the fix/use-glob-source branch July 6, 2023 17:09
SgtPooki added a commit that referenced this pull request Jul 11, 2023
* test: create add-dir benchmark

* chore(bench/add-dir): remove unused taskResult prop

* test(bench/add-dir): add kubo-direct test

* docs(bench/add-dir): ipfs-core node_modules output

* chore(bench/add-dir): kubo-direct doesnt pin files when adding

* chore(bench/add-dir): split helia benchmark by blockstore type (fs/mem)

* fix: ⚡ Double Digit Percentage Improvements. (#169)

* fix: ⚡ 2x improvement

Signed-off-by: Nishant Arora <[email protected]>

* fix: dag generation with parallelization at each level

---------

Signed-off-by: Nishant Arora <[email protected]>
Co-authored-by: Russell Dempsey <[email protected]>

* test: use globSource in add-dir benchmark (#171)

* fix: use glob source for importing directories

- Use `globSource` from ipfs-utils for import
- Make all impls return the same CID
- Remove the dir size - if the CID is the same that's good enough

* chore: fix linting

* chore: remove benchmark from workspaces

* test: align error and success output headers

---------

Signed-off-by: Nishant Arora <[email protected]>
Co-authored-by: Nishant Arora <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

4 participants