-
Notifications
You must be signed in to change notification settings - Fork 247
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
Try further optimize ReconstructSome for leopard 8+16 #274
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0b4e3cb
Optimize ReconstructSome for leopard 8+16
elias-orijtech 08a1be0
Try optimization: only add required shards errorBits/errLocs
liamsi 2d78890
Fix tests
liamsi ad60709
should be investigated properly instead: make errorLocs dependent on …
liamsi 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,17 +370,17 @@ func (r *leopardFF8) Split(data []byte) ([][]byte, error) { | |
|
||
func (r *leopardFF8) ReconstructSome(shards [][]byte, required []bool) error { | ||
if len(required) == r.totalShards { | ||
return r.reconstruct(shards, true) | ||
return r.reconstruct(shards, true, required) | ||
} | ||
return r.reconstruct(shards, false) | ||
return r.reconstruct(shards, false, required) | ||
} | ||
|
||
func (r *leopardFF8) Reconstruct(shards [][]byte) error { | ||
return r.reconstruct(shards, true) | ||
return r.reconstruct(shards, true, nil) | ||
} | ||
|
||
func (r *leopardFF8) ReconstructData(shards [][]byte) error { | ||
return r.reconstruct(shards, false) | ||
return r.reconstruct(shards, false, nil) | ||
} | ||
|
||
func (r *leopardFF8) Verify(shards [][]byte) (bool, error) { | ||
|
@@ -411,8 +411,8 @@ func (r *leopardFF8) Verify(shards [][]byte) (bool, error) { | |
return true, nil | ||
} | ||
|
||
func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool) error { | ||
if len(shards) != r.totalShards { | ||
func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool, required []bool) error { | ||
if len(shards) != r.totalShards || required != nil && len(required) < r.dataShards { | ||
return ErrTooFewShards | ||
} | ||
|
||
|
@@ -424,15 +424,19 @@ func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool) error { | |
// nothing to do. | ||
numberPresent := 0 | ||
dataPresent := 0 | ||
missingRequired := 0 | ||
for i := 0; i < r.totalShards; i++ { | ||
if len(shards[i]) != 0 { | ||
numberPresent++ | ||
if i < r.dataShards { | ||
dataPresent++ | ||
} | ||
} else if required != nil && required[i] { | ||
missingRequired++ | ||
} | ||
} | ||
if numberPresent == r.totalShards || !recoverAll && dataPresent == r.dataShards { | ||
if numberPresent == r.totalShards || !recoverAll && dataPresent == r.dataShards || | ||
required != nil && missingRequired == 0 { | ||
// Cool. All of the shards have data. We don't | ||
// need to do anything. | ||
return nil | ||
|
@@ -463,19 +467,19 @@ func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool) error { | |
for i := 0; i < r.parityShards; i++ { | ||
if len(shards[i+r.dataShards]) == 0 { | ||
errLocs[i] = 1 | ||
if LEO_ERROR_BITFIELD_OPT && recoverAll { | ||
if LEO_ERROR_BITFIELD_OPT && (recoverAll || (required != nil && required[i])) { | ||
errorBits.set(i) | ||
} | ||
} | ||
} | ||
for i := r.parityShards; i < m; i++ { | ||
errLocs[i] = 1 | ||
if LEO_ERROR_BITFIELD_OPT && recoverAll { | ||
if LEO_ERROR_BITFIELD_OPT && (recoverAll || (required != nil && required[i])) { | ||
errorBits.set(i) | ||
} | ||
} | ||
for i := 0; i < r.dataShards; i++ { | ||
if len(shards[i]) == 0 { | ||
if len(shards[i]) == 0 /*&& (recoverAll || (required != nil && required[i]))*/ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as in leopard.go: https://github.com/klauspost/reedsolomon/pull/274/files#r1511442291 |
||
errLocs[i+m] = 1 | ||
if LEO_ERROR_BITFIELD_OPT { | ||
errorBits.set(i + m) | ||
|
@@ -566,7 +570,7 @@ func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool) error { | |
|
||
// Add output | ||
for i, sh := range shards { | ||
if !recoverAll && i >= r.dataShards { | ||
if !recoverAll && i >= r.dataShards || required != nil && !required[i] { | ||
continue | ||
} | ||
if len(sh) == 0 { | ||
|
@@ -657,7 +661,7 @@ func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool) error { | |
} | ||
// Restore | ||
for i := 0; i < end; i++ { | ||
if len(sh[i]) != 0 { | ||
if len(sh[i]) != 0 || required != nil && !required[i] { | ||
continue | ||
} | ||
|
||
|
This file contains 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
Oops, something went wrong.
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.
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.
Uncommenting this leads to more significant improvements in
BenchmarkDecode1K
but will lead to a bunch of test failures (I think mostly becauseReconstructData
expects to reconstruct all original missing data). This can probably be fixed.