The live tests reached one shared bus and assert, read and remove the mesh's own objects by their fixed names, so packages run in parallel deleted what each other read and the suite passed only one package at a time; a red suite read as noise. internal/testbus starts a server per test, linked in at the nats-server release go.mod pins, and a test holds that pin to the catalogue's bus image and to the facts snapshot's bus when there is one, so the tests never run a bus the mesh does not. The waiter test read a timing (the most connections held at one look) and now reads the state it means (the fewest held across the wait). make check runs the packages in parallel under the race detector, with a timeout.
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package s2
|
|
|
|
import "sync"
|
|
|
|
// Table size constants
|
|
const (
|
|
betterLongTableBits = 17
|
|
betterLongTableSize = 1 << betterLongTableBits // 131072
|
|
|
|
betterShortTableBits = 14
|
|
betterShortTableSize = 1 << betterShortTableBits // 16384
|
|
|
|
betterSnappyLongTableBits = 16
|
|
betterSnappyLongTableSize = 1 << betterSnappyLongTableBits // 65536
|
|
|
|
bestLongTableBits = 19
|
|
bestLongTableSize = 1 << bestLongTableBits // 524288
|
|
|
|
bestShortTableBits = 16
|
|
bestShortTableSize = 1 << bestShortTableBits // 65536
|
|
)
|
|
|
|
type betterTables struct {
|
|
lTable [betterLongTableSize]uint32
|
|
sTable [betterShortTableSize]uint32
|
|
}
|
|
|
|
var betterTablePool = sync.Pool{New: func() any { return &betterTables{} }}
|
|
|
|
// betterSnappyTables holds better-snappy compression hash tables.
|
|
type betterSnappyTables struct {
|
|
lTable [betterSnappyLongTableSize]uint32
|
|
sTable [betterShortTableSize]uint32
|
|
}
|
|
|
|
var betterSnappyTablePool = sync.Pool{New: func() any { return &betterSnappyTables{} }}
|
|
|
|
// bestTables holds best compression hash tables.
|
|
type bestTables struct {
|
|
lTable [bestLongTableSize]uint64
|
|
sTable [bestShortTableSize]uint64
|
|
}
|
|
|
|
var bestTablePool = sync.Pool{New: func() any { return &bestTables{} }}
|
|
|
|
// getBetterTables gets a zeroed betterTables from the pool.
|
|
func getBetterTables() *betterTables {
|
|
t := betterTablePool.Get().(*betterTables)
|
|
*t = betterTables{}
|
|
return t
|
|
}
|
|
|
|
// getBetterSnappyTables gets a zeroed betterSnappyTables from the pool.
|
|
func getBetterSnappyTables() *betterSnappyTables {
|
|
t := betterSnappyTablePool.Get().(*betterSnappyTables)
|
|
*t = betterSnappyTables{}
|
|
return t
|
|
}
|
|
|
|
// getBestTables gets a zeroed bestTables from the pool.
|
|
func getBestTables() *bestTables {
|
|
t := bestTablePool.Get().(*bestTables)
|
|
*t = bestTables{}
|
|
return t
|
|
}
|