-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 benchmark for loading chunks and chunk descs. #604
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -884,3 +884,74 @@ func verifyIndexedState(i int, t *testing.T, b incrementalBatch, indexedFpsToMet | |
} | ||
} | ||
} | ||
|
||
var fpStrings = []string{ | ||
"b004b821ca50ba26", | ||
"b037c21e884e4fc5", | ||
"b037de1e884e5469", | ||
} | ||
|
||
func BenchmarkLoadChunksSequentially(b *testing.B) { | ||
p := persistence{ | ||
basePath: "fixtures", | ||
} | ||
sequentialIndexes := make([]int, 47) | ||
for i := range sequentialIndexes { | ||
sequentialIndexes[i] = i | ||
} | ||
|
||
var fp clientmodel.Fingerprint | ||
for i := 0; i < b.N; i++ { | ||
for _, s := range fpStrings { | ||
fp.LoadFromString(s) | ||
cds, err := p.loadChunks(fp, sequentialIndexes, 0) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
if len(cds) == 0 { | ||
b.Error("could not read any chunks") | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkLoadChunksRandomly(b *testing.B) { | ||
p := persistence{ | ||
basePath: "fixtures", | ||
} | ||
randomIndexes := []int{1, 5, 6, 8, 11, 14, 18, 23, 29, 33, 42, 46} | ||
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. Would one not want to load all 47 chunks here too (randomly), unless you don't care about comparing it to the benchmark above? 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. Random order is not a realistic scenario. AFAIK, the load is either completely sequential as above, or it has "gaps", which I try to simulate here. No comparison of the two benchmarks intended. This is all only to play with the load methods later. |
||
|
||
var fp clientmodel.Fingerprint | ||
for i := 0; i < b.N; i++ { | ||
for _, s := range fpStrings { | ||
fp.LoadFromString(s) | ||
cds, err := p.loadChunks(fp, randomIndexes, 0) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
if len(cds) == 0 { | ||
b.Error("could not read any chunks") | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkLoadChunkDescs(b *testing.B) { | ||
p := persistence{ | ||
basePath: "fixtures", | ||
} | ||
|
||
var fp clientmodel.Fingerprint | ||
for i := 0; i < b.N; i++ { | ||
for _, s := range fpStrings { | ||
fp.LoadFromString(s) | ||
cds, err := p.loadChunkDescs(fp, clientmodel.Latest) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
if len(cds) == 0 { | ||
b.Error("could not read any chunk descs") | ||
} | ||
} | ||
} | ||
} |
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.
May I ask: why exactly 47?
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.
Ah, because that's in the fixture, I guess...