-
Notifications
You must be signed in to change notification settings - Fork 80
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
Batch ClaimAllocations during ProveCommitAggregate #1304
Conversation
943c209
to
7cc207e
Compare
7cc207e
to
b92f4a6
Compare
actors/miner/src/ext.rs
Outdated
#[serde(with = "bigint_ser")] | ||
pub claimed_space: BigInt, | ||
pub sector: SectorNumber, |
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.
(Thinking out loud) I see how we need some change here: when batching across sectors, we need some way to return how much claimed space is associated with each sector, because the caller doesn't know.
The parameters are not grouped by sector, so it makes sense that the result is not grouped by sector either: there could be multiple claims for a single sector.
We don't need to return the sector number though, and there's now some redundancy between the BatchReturn and the list of results. I think the simplest thing would be to drop the BatchReturn, and return a vector of claim results that is parallel to (so the same length as) the parameter and contains only the claimed space. The space is zero for failures. The caller can line this up with the parameters to group by sector number.
(A similar but more complicated scheme would keep the batch return but drop the failed results, but then iterating to line up is hard. I don't think we should optimise for the failure case).
@ZenGround0 what do you think here?
df56d14
to
4108592
Compare
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.
Thanks this looks pretty good.
I am very reluctant to even temporarily introduce this duplication of the single/batch calls though. Thanks for attempting to keep this PR small. Can you try to do the refactor against master first though, so that both call sites are using a path that will allow batching, then add the batching?
ret_gen.add_success(); | ||
sector_claims | ||
.push(SectorAllocationClaimResult { claimed_space: claim_alloc.size.0.into() }); |
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.
This pattern makes me quite nervous. I wish we had try_map
in stable.
For now please explicitly check that sector_claims ends up the right size, and abort (USR_ASSERTION_FAILED) if not.
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 here, but wouldn't map
over params.allocations be sufficient to ensure that the result array stays parallel?
Also, given BatchReturn
is no longer part of ClaimAllocationsReturn
, I'll remove the ret_gen
tracking, though this drops the nuance of specific error codes from the error message (it's already missing from the return value now).
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 don't know if this is valid. Is it possible to have a valid but zero-sized claim?
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 think map
is hard to use if you want to bubble a result with ?
, like at 433 (unless you want to deal with a Map<Result<>>
. That's why try_map
.
This logic of checking for zero size is valid at the moment, because the minimum Allocation size is positive. It's probably safe forever, just nervous.
ret_gen.add_success(); | ||
sector_claims | ||
.push(SectorAllocationClaimResult { claimed_space: claim_alloc.size.0.into() }); |
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 think map
is hard to use if you want to bubble a result with ?
, like at 433 (unless you want to deal with a Map<Result<>>
. That's why try_map
.
This logic of checking for zero size is valid at the moment, because the minimum Allocation size is positive. It's probably safe forever, just nervous.
Work towards #1278.
TODOs
Batching of claim allocations saves both messaging overheads and state mutation costs by only updating the DataCap actor once. The full stack traces can be found here.
The total gas costs for the PCA message drops approximately ~25%
Before:
After: