Repository navigation
Commit fb7b73f
perf: merge and recount each unique subgraph object once in incremental loop
Duplicated words share one subgraph object via the build cache, but the
incremental update loop merged and recounted per occurrence, so duplicates
diverged into equal-but-distinct copies on their first merge. Memoizing by
object identity does the work once per unique word; the resulting Counter is
shared across occurrences (comp_counts entries are only ever read).
Zipf corpus (20k words, 2k vocab, 300 merges), byte-identical output:
- BPE: 0.362s -> 0.172s, peak 35.8MB -> 31.5MB
- BNE: 0.501s -> 0.352s, peak 37.8MB -> 35.3MB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 25b3773 commit fb7b73f
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | | - | |
101 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
0 commit comments