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

speedup collection struct #75

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

vagabondkjo
Copy link
Contributor

This PR speeds up the collection struct.

1. Some implemented ideas

a. Add new element

  • improve finding location to add an element into the element list of a POV entry using binary search tree instead of the old linked list approach.
  • try to make balanced search tree if we got number of interations exceed a dynamic number (threshold). Ideally, build this once, and it should help to speedup finding procedure later.

b. Optimize accessing to memory

  • fit encoded 32 occupation flags per read for 32 POV entries instead of currently doing per check per read the flags buffer.

c. Optimize checking occupation flag

  • use trailing-zeros/leading-zeros intrinsics to jump-out/ignore some bits quickly

d. Optimize cleanup function

  • use smaller buffer and do resetting/setting memory at least as possible.
  • don't need to rebuild/copy elements buffer, because we only need to modify element's povIndex property
  • quick stop by checking population info

2. Profile

  • the performance has been improved around 20-30%.

image

Copy link
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

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

Thanks, this is awesome work. Please revise according to my comments.

Please also consider to add some of the "Some implemented ideas" mentioned above in comments in the source code.

src/smart_contracts/qpi.h Show resolved Hide resolved
src/smart_contracts/qpi.h Outdated Show resolved Hide resolved
src/smart_contracts/qpi.h Outdated Show resolved Hide resolved
src/smart_contracts/qpi.h Outdated Show resolved Hide resolved
src/smart_contracts/qpi.h Outdated Show resolved Hide resolved
src/smart_contracts/qpi.h Show resolved Hide resolved
src/smart_contracts/qpi.h Show resolved Hide resolved
@vagabondkjo
Copy link
Contributor Author

@philippwerner thanks and addressed your comments.

Copy link
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

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

Great, thanks. Time for merging.

@philippwerner philippwerner merged commit 68487fe into qubic:develop Mar 20, 2024
1 check passed
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