mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
state: fix redundant reconciliation in typeDecodeDatabase.Lookup()
Simple microbenchmark for save+load of a pgalloc.memAcctSet: Before this CL: ``` goos: linux goarch: amd64 pkg: pkg/sentry/pgalloc/pgalloc cpu: Intel(R) Xeon(R) CPU @ 2.60GHz BenchmarkMemAcctSetSaveLoad BenchmarkMemAcctSetSaveLoad/1000 BenchmarkMemAcctSetSaveLoad/1000-48 362 3313192 ns/op BenchmarkMemAcctSetSaveLoad/10000 BenchmarkMemAcctSetSaveLoad/10000-48 33 35237918 ns/op BenchmarkMemAcctSetSaveLoad/100000 BenchmarkMemAcctSetSaveLoad/100000-48 3 360797304 ns/op PASS ``` After this CL: ``` goos: linux goarch: amd64 pkg: pkg/sentry/pgalloc/pgalloc cpu: Intel(R) Xeon(R) CPU @ 2.60GHz BenchmarkMemAcctSetSaveLoad BenchmarkMemAcctSetSaveLoad/1000 BenchmarkMemAcctSetSaveLoad/1000-48 417 2837200 ns/op BenchmarkMemAcctSetSaveLoad/10000 BenchmarkMemAcctSetSaveLoad/10000-48 38 30813388 ns/op BenchmarkMemAcctSetSaveLoad/100000 BenchmarkMemAcctSetSaveLoad/100000-48 4 311275972 ns/op PASS ``` PiperOrigin-RevId: 663494805
This commit is contained in:
+1
-1
@@ -204,7 +204,7 @@ var singleFieldOrder = []int{0}
|
||||
//
|
||||
// This method never returns nil.
|
||||
func (tbd *typeDecodeDatabase) Lookup(id typeID, typ reflect.Type) *reconciledTypeEntry {
|
||||
if len(tbd.byID) > int(id) && tbd.byID[id-1] != nil {
|
||||
if len(tbd.byID) >= int(id) && tbd.byID[id-1] != nil {
|
||||
// Already reconciled.
|
||||
return tbd.byID[id-1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user