mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
This significantly optimizes the (*Policy).RouteID() and (*Policy).Checksum() methods for both speed and memory usage. A new method (*Policy).ChecksumWithID(uint64) can be used to skip a call to RouteID() if the ID is already known. Checksum() is implemented in terms of this new method, and will always recompute the route ID on each call. RouteID() does not allocate heap memory. Checksum() may allocate heap memory, depending on which fields are set. If all of the following are true, Checksum() makes zero allocations: 1. The policy uses redirect or direct-response mode 2. The policy has no sub-policies 3. The policy has no response header rewrite config
14 lines
229 B
Go
14 lines
229 B
Go
package config
|
|
|
|
import (
|
|
"runtime/debug"
|
|
"sync"
|
|
|
|
"github.com/valyala/bytebufferpool"
|
|
)
|
|
|
|
func DebugResetPools() {
|
|
checksumBufferPool = bytebufferpool.Pool{}
|
|
policyPool = sync.Pool{New: policyPool.New}
|
|
debug.FreeOSMemory()
|
|
}
|