-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(fr32): correctly calculate the todo size under low core counts #12884
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
base: fix/unpadreader-panics
Are you sure you want to change the base?
fix(fr32): correctly calculate the todo size under low core counts #12884
Conversation
I'm not up on the specifics of this PR, but I know it's been open for a long time. What is the owrst case that could happen if this code is "wrong"? I'm trying to gage if we'd be better off to just merge than keep it open. |
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.
Pull Request Overview
This PR ensures the unpadReader
never schedules more work than its buffer can hold under low core counts by clamping the todo
size, and it bolsters the test suite with reliability checks and a new edge-case test.
- Clamp the
todo
chunk size inreadInner
to thework
buffer length - Add
TestUnpadReaderBufWithSmallWorkBuf
to verify behavior with very small buffers - Strengthen existing tests by validating the number of bytes read from
rand.Read
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
storage/sealer/fr32/readers.go | Clamp todo to len(r.work) in readInner to prevent overflow |
storage/sealer/fr32/readers_test.go | Add new buffer-size edge-case test and tighten randomness reads in tests |
Comments suppressed due to low confidence (1)
storage/sealer/fr32/readers_test.go:40
- [nitpick] The test name is a bit verbose; renaming it to
TestUnpadReaderWithSmallWorkBuf
would align better with existing test naming patterns and improve readability.
func TestUnpadReaderBufWithSmallWorkBuf(t *testing.T) {
Co-authored-by: Copilot <[email protected]>
There's less data to read each time, which affects performance, I guess. |
I've found it hard to context switch deep enough to grok either this or the previous attempt to edit this code so it's hard for me to weigh in.
This seems right but I don't have time to validate it. I think if we just go ahead and roll this out, we'd find out about problems with it if we started hearing about CommP mismatches. We might just have to 🤞 and go ahead unless we have someone else who has the brainspace to drop in here and grok what this code is doing and give a proper 👍 . Maybe Kuba could do that when he's back from his break? |
Related Issues
Fixes #9324
Based on #12491.
Proposed Changes
Currently, the unpadReader's work size is calculated using MTTresh * mtChunkCount(sz). When the core count is low, this may cause the todo length to exceed
len(work)
.In the current implementation, the length of
out
is actually expanded automatically by Go's underlying mechanisms, making adjustments quite troublesome.There are two feasible solutions:
I'm not entirely sure if other conditions could also lead to similar issues, so for now, I've chosen the second approach. I added a check when calculating todo to prevent overflow:
Additionally I’ve also fixed the CI.
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that: