test(bench): pick the deltified benchmark objects by chain end and delta status (GO-006)
The size filter excluded every delta of the generated fixture, so the deltified objects silently fell back to a plain packed blob. Select on the delta flag and the chainEnd type only, and fail when none qualifies.
- commit
- eb2657acd9c0c0b172112e3f9a11bd2dbff7d589
- author
- brice · · 2026-10-10 22:15 UTC
- parent
- b1a375f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +10 -11
M bench_test.go +10 -11
| @@ -125,8 +125,13 @@ func (fx *benchFixture) finish(b *testing.B, gitDir string) { | |||
| 125 | 125 | var id ObjectID | |
| 126 | 126 | copy(id[:], p.idx.id(i)) | |
| 127 | 127 | switch { | |
| 128 | - | case h.isDelta() && h.size > 200: | |
| 129 | - | typ, _ := p.chainEnd(off, h) | |
| 128 | + | case h.isDelta(): | |
| 129 | + | // The size of a delta is that of the delta, not of the | |
| 130 | + | // object: do not filter on it. | |
| 131 | + | typ, err := p.chainEnd(off, h) | |
| 132 | + | if err != nil { | |
| 133 | + | b.Fatal(err) | |
| 134 | + | } | |
| 130 | 135 | if typ == TypeBlob && fx.deltaBlob.IsZero() { | |
| 131 | 136 | fx.deltaBlob = id | |
| 132 | 137 | } | |
| @@ -146,15 +151,9 @@ func (fx *benchFixture) finish(b *testing.B, gitDir string) { | |||
| 146 | 151 | if fx.looseBlob.IsZero() { | |
| 147 | 152 | fx.looseBlob = fx.packedBlob | |
| 148 | 153 | } | |
| 149 | - | if fx.deltaBlob.IsZero() { | |
| 150 | - | fx.deltaBlob = fx.packedBlob | |
| 151 | - | } | |
| 152 | - | if fx.deltaTree.IsZero() { | |
| 153 | - | var c Commit | |
| 154 | - | if err := fx.r.ReadCommit(fx.headCommit, &c); err != nil { | |
| 155 | - | b.Fatal(err) | |
| 156 | - | } | |
| 157 | - | fx.deltaTree = c.Tree | |
| 154 | + | if fx.deltaBlob.IsZero() || fx.deltaTree.IsZero() { | |
| 155 | + | b.Fatalf("no deltified blob (%v) or tree (%v) in the packs of %s: the deltified benchmarks would measure something else", | |
| 156 | + | !fx.deltaBlob.IsZero(), !fx.deltaTree.IsZero(), gitDir) | |
| 158 | 157 | } | |
| 159 | 158 | if fx.bigTree.IsZero() { | |
| 160 | 159 | var c Commit | |
| @@ -125,8 +125,13 @@ func (fx *benchFixture) finish(b *testing.B, gitDir string) { | |||||
| 125 | var id ObjectID | 125 | var id ObjectID | ||
| 126 | copy(id[:], p.idx.id(i)) | 126 | copy(id[:], p.idx.id(i)) | ||
| 127 | switch { | 127 | switch { | ||
| 128 | - | case h.isDelta() && h.size > 200: | 128 | + | case h.isDelta(): |
| 129 | - | typ, _ := p.chainEnd(off, h) | 129 | + | // The size of a delta is that of the delta, not of the |
| 130 | + | // object: do not filter on it. | |||
| 131 | + | typ, err := p.chainEnd(off, h) | |||
| 132 | + | if err != nil { | |||
| 133 | + | b.Fatal(err) | |||
| 134 | + | } | |||
| 130 | if typ == TypeBlob && fx.deltaBlob.IsZero() { | 135 | if typ == TypeBlob && fx.deltaBlob.IsZero() { | ||
| 131 | fx.deltaBlob = id | 136 | fx.deltaBlob = id | ||
| 132 | } | 137 | } | ||
| @@ -146,15 +151,9 @@ func (fx *benchFixture) finish(b *testing.B, gitDir string) { | |||||
| 146 | if fx.looseBlob.IsZero() { | 151 | if fx.looseBlob.IsZero() { | ||
| 147 | fx.looseBlob = fx.packedBlob | 152 | fx.looseBlob = fx.packedBlob | ||
| 148 | } | 153 | } | ||
| 149 | - | if fx.deltaBlob.IsZero() { | 154 | + | if fx.deltaBlob.IsZero() || fx.deltaTree.IsZero() { |
| 150 | - | fx.deltaBlob = fx.packedBlob | 155 | + | b.Fatalf("no deltified blob (%v) or tree (%v) in the packs of %s: the deltified benchmarks would measure something else", |
| 151 | - | } | 156 | + | !fx.deltaBlob.IsZero(), !fx.deltaTree.IsZero(), gitDir) |
| 152 | - | if fx.deltaTree.IsZero() { | |||
| 153 | - | var c Commit | |||
| 154 | - | if err := fx.r.ReadCommit(fx.headCommit, &c); err != nil { | |||
| 155 | - | b.Fatal(err) | |||
| 156 | - | } | |||
| 157 | - | fx.deltaTree = c.Tree | |||
| 158 | } | 157 | } | ||
| 159 | if fx.bigTree.IsZero() { | 158 | if fx.bigTree.IsZero() { | ||
| 160 | var c Commit | 159 | var c Commit | ||