Tune bootstrap checkpoint probe spans · Entire
Tune bootstrap checkpoint probe spans
3d8ba82→main·
Soph·3mo ago·2 files·+89 added/-1 removed
Sessions
8cefb463e4c2View transcript
Can you take a look at the go code (wasm) in /Users/soph/Work/entire/devenv/entire-io-worktree1 based a bit on that I wonder if something like this can be build:Codex·GPT-5.4·1 step
Changes
2
- internal/strategy/bootstrap
Mbootstrap.go+27/-1
Mbootstrap_test.go+62
394 unmodified lines
395
396
397
398
399
400
401
399
402
403
404
11 unmodified lines
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
394 unmodified lines
}
if result, ok := probeCache[prevHash.String()+":"+strconv.Itoa(bestIdx)]; ok && !result.tooLarge && len(result.data) > 0 {
prefetched[chain[bestIdx]] = result.data
prevSpan = adaptiveNextProbeSpan(p.BatchMaxPack, len(result.data), bestIdx-prevIdx, len(chain)-1-bestIdx)
} else {
prevSpan = bestIdx - prevIdx
}
prevSpan = bestIdx - prevIdx
prevIdx = bestIdx
prevHash = chain[bestIdx]
checkpoints = append(checkpoints, prevHash)
11 unmodified lines
data []byte
}
func adaptiveNextProbeSpan(limit int64, measuredBytes int, selectedSpan int, remaining int) int {
if selectedSpan < 1 {
selectedSpan = 1
}
if remaining < 1 {
return selectedSpan
}
if limit <= 0 || measuredBytes <= 0 {
if selectedSpan > remaining {
return remaining
}
return selectedSpan
}
next := int((int64(selectedSpan) * limit) / int64(measuredBytes))
if next < 1 {
next = 1
}
if next > remaining {
next = remaining
}
return next
}
func fetchPackForProbe(ctx context.Context, p Params, ref planner.DesiredRef, want, have plumbing.Hash, limit int64) ([]byte, bool, error) {
desired := singleGP(ref.SourceRef, ref.TargetRef, want)
haves := planner.SingleHaveMap(have)
Minternal/strategy/bootstrap/bootstrap.go+27/-1
122 unmodified lines
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
122 unmodified lines
}
}
func TestAdaptiveNextProbeSpan(t *testing.T) {
tests := []struct {
name string
limit int64
measured int
selectedSpan int
remaining int
want int
}{
{
name: "grows span when measured pack is far below limit",
limit: 1000,
measured: 250,
selectedSpan: 4,
remaining: 20,
want: 16,
},
{
name: "caps growth at remaining commits",
limit: 1000,
measured: 200,
selectedSpan: 4,
remaining: 6,
want: 6,
},
{
name: "keeps minimum span of one",
limit: 1000,
measured: 4000,
selectedSpan: 1,
remaining: 10,
want: 1,
},
{
name: "falls back to selected span without measurements",
limit: 1000,
measured: 0,
selectedSpan: 3,
remaining: 10,
want: 3,
},
{
name: "caps fallback span at remaining",
limit: 0,
measured: 0,
selectedSpan: 8,
remaining: 5,
want: 5,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := adaptiveNextProbeSpan(tt.limit, tt.measured, tt.selectedSpan, tt.remaining)
if got != tt.want {
t.Fatalf("adaptiveNextProbeSpan(%d, %d, %d, %d) = %d, want %d",
tt.limit, tt.measured, tt.selectedSpan, tt.remaining, got, tt.want)
}
})
}
}
type fakeBootstrapSource struct {
fetchPack func(context.Context, *gitproto.Conn, map[plumbing.ReferenceName]gitproto.DesiredRef, map[plumbing.ReferenceName]plumbing.Hash) (io.ReadCloser, error)
}