-
- Notifications
You must be signed in to change notification settings - Fork 679
Improve memory usage for weakHeap sorting #68
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits Select commit Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand this change. Before, there was one byte per 8 elements (1 bit per element), if I understood this correctly:
8 elements -> blen=1
9 elements -> blen=2
Afterwards, with the change, this becomes:
8 elements -> blen=1
9 elements -> blen=1 (is this correct?)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
Before:
8 elements -> blen = 1
9 elements -> blen = 2
After:
8 elements -> blen = 1
9 elements -> blen = 1
32 elements -> blen = 1
33 elements -> blen = 2
64 elements -> blen = 2
So for 32 elements now used full space of 32-bit word
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but my impression was that the bitset needs one bit per element? Or does it calculate the number of 32-bit ints now and
blenisn't synonymous for byteLength anymore?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, bitset just add one extra bit per element.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if there are 3 elements, wouldn't it need 3 distinct bits still (one per element)? Otherwise, let's say there are three elements, the bitset would be
0011b, unable to distinguish this from element 1 and 2 being set?Or, let me rephrase: If there are 32 elements, the bitset would need 32 bits. With 8 bits per byte, that are 4 bytes, not 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I hope Uint32Array is more performant. In JS version it's true
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Than an Uint8Array? Even though an Uint32Array involves additional (obviously hard to understand ^^) shifts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean
Array<bool>orArray<u8>which store only one bit of 8-bits current version slower of course but we loose 7-bits and our memory usage is worst. So this is balance between memory usage/speed. I mean current version faster previous when I used 8-bit vector inside 32-bit array =)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
Array<bool>doesn't make sense because it wastes 7/8 bits, but why wouldn't u8 work, storing 8 element bits per u8, over an u32 storing 32 element bits per u32?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's what I wrote and older version works perfectly, but we loose 24-bits and use the same xor-shifts techniques for access to bits. Now I rewrite this to use full 32-bits range