Skip to content
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

Improve performance #83

Closed
wants to merge 11 commits into from
Closed

Improve performance #83

wants to merge 11 commits into from

Conversation

dignifiedquire
Copy link
Member

@dignifiedquire dignifiedquire commented Dec 15, 2016

  • Drop peer request queue, we don't need it at this point
  • reduce key to string conversions
  • aggregate wantlist generation
  • properly cancel wants that we canceld
  • extract benchmarks and expand them

Includes #82

@dignifiedquire
Copy link
Member Author

There were issues with shutting down in our tests & benchmarks. It seems I finally got to the bottom of those:

now we don't need the timeout anymore test/network/gen-network.node.js

@dignifiedquire
Copy link
Member Author

Upgraded benchmarks are currently running locally:

  2 nodes - 1 blocks/node - 388ms
  2 nodes - 10 blocks/node - 554ms
  2 nodes - 100 blocks/node - 1478ms
  5 nodes - 1 blocks/node - 845ms
  5 nodes - 10 blocks/node - 3105ms
  5 nodes - 100 blocks/node - 13860ms
  10 nodes - 1 blocks/node - 3192ms
  10 nodes - 10 blocks/node - 36894ms

Where one block is 1024 bytes.

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Dec 16, 2016

Latest commit improves the benchmark to

  2 nodes - 1 blocks/node - 353ms
  2 nodes - 10 blocks/node - 442ms
  2 nodes - 100 blocks/node - 437ms
  5 nodes - 1 blocks/node - 546ms
  5 nodes - 10 blocks/node - 661ms
  5 nodes - 100 blocks/node - 2455ms
  10 nodes - 1 blocks/node - 692ms
  10 nodes - 10 blocks/node - 1156ms
  10 nodes - 100 blocks/node - 49132ms

@dignifiedquire dignifiedquire changed the title Improve pref Improve performance Dec 16, 2016
@daviddias daviddias self-requested a review December 16, 2016 19:14
@daviddias
Copy link
Member

One thing that we should do is make things like peerId.toB58String() become a cached property of the PeerId class itself, this way, instead of forcing the developer (in bitswap us, but for any app on top too) to remember to cache it always, V8 will start inlining every peerId.toB58String() as soon as the first time it is called.

To save even more time, just make the PeerId class immutable all the way and cache all of these:
https://github.com/libp2p/js-peer-id/blob/master/src/index.js#L62-L68, then we can call toB58String or toJSON as many times we want and it will have 0 cost thanks to V8 inlining magic

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Dec 18, 2016

@diasdavid funny you mention that: libp2p/js-peer-id#44 😝

@daviddias
Copy link
Member

@dignifiedquire PR's everywhere \o/ ! :D

@dignifiedquire
Copy link
Member Author

Closing in favor of #84

@dignifiedquire dignifiedquire removed their assignment Dec 20, 2016
@dignifiedquire dignifiedquire removed the status/in-progress In progress label Dec 20, 2016
@daviddias daviddias deleted the new branch December 21, 2016 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants