forked from BobuSumisu/aho-corasick
-
Notifications
You must be signed in to change notification settings - Fork 0
perf: scale chainSample's budget down at chunk size #37
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5771575
perf: scale chainSample's budget down at chunk size
ahrav 0de9278
review: bench regime asserted at run GOMAXPROCS, test fixture reuse, …
ahrav 0a2b435
review: gate SP benchmarks on the 8-proc worker complement
ahrav fa4a0a9
review: scope the CPU gate to geometry-pinned benchmarks
ahrav 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package ahocorasick | ||
|
|
||
| // routingpreserve_test.go - tripwire for the dual-vs-single routing | ||
| // verdict. chainSample's budget scales with input size | ||
| // (chainSampleSmallMax), so this asserts the ROUTING VERDICT (not the | ||
| // raw votes) on the corpus shapes whose routing the calibration | ||
| // constants promise, at sizes on both sides of the budget threshold. A | ||
| // sampling change that flips one of these mis-routes a scan family: | ||
| // word-like dense input loses the dual-cursor win, or shallow-chain | ||
| // dense input loses the single-cursor win (measured 1.4x on that | ||
| // shape). | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestRoutingPreserved(t *testing.T) { | ||
| patterns, err := readPatterns("./test_data/NSF-ordlisten.cleaned.txt") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| ibsen := benchReadFile(t, "./test_data/Ibsen.txt") | ||
| if len(ibsen) < 96<<10 { | ||
| t.Fatalf("Ibsen.txt fixture too short: %d bytes, need %d", len(ibsen), 96<<10) | ||
| } | ||
| tr := buildStopByte16Trie(t, patterns[:10000]) | ||
|
|
||
| wordlike := concat(patterns[:10000], 256<<10) | ||
| fs := spFalseStartCorpus(tr.rootStopBytes[0], 256<<10) | ||
|
|
||
| // Routing the calibration constants promise; must hold at both | ||
| // sampling budgets (below and at-or-above chainSampleSmallMax). | ||
| for _, c := range []struct { | ||
| name string | ||
| input []byte | ||
| want bool | ||
| }{ | ||
| // Long-chain dense input routes dual at every scale, chunk or whole. | ||
|
ahrav marked this conversation as resolved.
|
||
| {"wordlike-12k", wordlike[:12<<10], true}, | ||
| {"wordlike-16k", wordlike[:16<<10], true}, | ||
| {"wordlike-32k", wordlike[:32<<10], true}, | ||
| {"wordlike-96k", wordlike[:96<<10], true}, | ||
| // Depth-1 excursions route single despite maximal density. | ||
| {"falsestart-12k", fs[:12<<10], false}, | ||
| {"falsestart-16k", fs[:16<<10], false}, | ||
| {"falsestart-96k", fs[:96<<10], false}, | ||
| // Natural text (short chains, sparse-ish) routes single. | ||
| {"ibsen-12k", ibsen[:12<<10], false}, | ||
| {"ibsen-48k", ibsen[:48<<10], false}, | ||
| {"ibsen-96k", ibsen[:96<<10], false}, | ||
| } { | ||
| if got := tr.dualWorthwhile(c.input); got != c.want { | ||
|
ahrav marked this conversation as resolved.
|
||
| t.Errorf("%s: dualWorthwhile=%v, want %v (routing flipped)", c.name, got, c.want) | ||
| } | ||
| } | ||
|
|
||
| // Characterization only: separator-broken corpora sit near the vote | ||
| // thresholds, so their verdicts are logged rather than asserted; | ||
| // compare against BenchmarkSPGray when a flip appears. | ||
| for _, gap := range []int{2, 4, 8} { | ||
| var sb []byte | ||
| i := 0 | ||
| for len(sb) < 96<<10 { | ||
| sb = append(sb, patterns[i%10000]...) | ||
| for g := 0; g < gap; g++ { | ||
| sb = append(sb, 'x') | ||
| } | ||
| i++ | ||
| } | ||
| for _, size := range []int{12 << 10, 96 << 10} { | ||
| t.Logf("gray gap%d %dKiB: dualWorthwhile=%v", | ||
| gap, size>>10, tr.dualWorthwhile(sb[:size])) | ||
| } | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.