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

add a command for compacting sector numbers bitfield #4640

Merged
merged 5 commits into from
Jul 22, 2021

Conversation

whyrusleeping
Copy link
Member

still in progress, would love it if someone could finish this up for me.

@Stebalien
Copy link
Member

So, I think the right approach here would be to:

  1. Set a target size (no idea what this should be).
  2. When we hit twice that size, compact to that size.

The compaction algorithm is actually pretty simple: be greedy.

  1. Expand the bitfield into runs of 0s: (offset, length).
  2. Sort the runs by length.
  3. Starting at the shortest run of 0s, turn that run of 0s into a run of 1s in the original bitfield.

This is optimal (mostly) because it (a) removes two runs for each step and (b) allocates the least sector numbers when doing this.

This is mostly (optimal) because it doesn't account for the cost of encoding a run. Smaller runs are cheeper to encode than larger ones. However, I don't think this matters in practice.


I'm happy to take this on, but I'm not sure what the target size should be.

Signed-off-by: Jakub Sztandera <[email protected]>
@Kubuxu
Copy link
Contributor

Kubuxu commented Oct 29, 2020

For now, I wrote a manual version. The issue being that we need to know which sectors are still being commited, which are abandonned and so on.
Also if we do anything automatic, then we should alert big miners with a lot of sectors.

but the algorithm you are speaking of could be used as --mask-auto=N or something like that

@Stebalien
Copy link
Member

This may be a case for https://rachelbythebay.com/w/2020/10/26/num/. Where, ideally, the number you type in is the number of sector IDs remaining.

@Kubuxu
Copy link
Contributor

Kubuxu commented Oct 29, 2020

I would say the number would be a number of sectors that will be marked as unavaliable by the operation. (the bigger the number, the more risk/harm there is).

@Stebalien
Copy link
Member

Also works. I just want miners to understand that there's a tradeoff.

@whyrusleeping whyrusleeping requested a review from arajasek as a code owner May 7, 2021 01:26
@whyrusleeping whyrusleeping requested a review from a team as a code owner July 22, 2021 14:02
@magik6k magik6k force-pushed the feat/compact-sectors-numbers-cmd branch from a4ffd1a to 0656b62 Compare July 22, 2021 14:04
Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Looks landable, but probably should get another approval first

@magik6k magik6k force-pushed the feat/compact-sectors-numbers-cmd branch from 7ee0f01 to 15a6995 Compare July 22, 2021 14:31
@magik6k magik6k merged commit 2d40089 into master Jul 22, 2021
@magik6k magik6k deleted the feat/compact-sectors-numbers-cmd branch July 22, 2021 17:16
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.

4 participants