mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
compress/flate: move big non-pointer arrays to end of compressor
The compressor type is fairly large: 656616 bytes on amd64. Before this patch, it had fields of slice and interface type near the end of the struct. As those types always contain pointers, the ptrBytes value in the type descriptor was quite large. That forces the garbage collector to do extra work scanning for pointers, and wastes a bit of executable space recording the gcmask for the type. This patch moves the arrays to the end of the type, fixing those minor issues. Change-Id: I849a75a19cc61137c8797a1ea5a4c97e0f69b4db Reviewed-on: https://go-review.googlesource.com/c/go/+/707596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
This commit is contained in:
parent
4ca048cc32
commit
8d6d14f5d6
1 changed files with 12 additions and 10 deletions
|
|
@ -89,16 +89,6 @@ type compressor struct {
|
|||
step func(*compressor) // process window
|
||||
bestSpeed *deflateFast // Encoder for BestSpeed
|
||||
|
||||
// Input hash chains
|
||||
// hashHead[hashValue] contains the largest inputIndex with the specified hash value
|
||||
// If hashHead[hashValue] is within the current window, then
|
||||
// hashPrev[hashHead[hashValue] & windowMask] contains the previous index
|
||||
// with the same hash value.
|
||||
chainHead int
|
||||
hashHead [hashSize]uint32
|
||||
hashPrev [windowSize]uint32
|
||||
hashOffset int
|
||||
|
||||
// input window: unprocessed data is window[index:windowEnd]
|
||||
index int
|
||||
window []byte
|
||||
|
|
@ -117,6 +107,18 @@ type compressor struct {
|
|||
maxInsertIndex int
|
||||
err error
|
||||
|
||||
// Input hash chains
|
||||
// hashHead[hashValue] contains the largest inputIndex with the specified hash value
|
||||
// If hashHead[hashValue] is within the current window, then
|
||||
// hashPrev[hashHead[hashValue] & windowMask] contains the previous index
|
||||
// with the same hash value.
|
||||
// These are large and do not contain pointers, so put them
|
||||
// near the end of the struct so the GC has to scan less.
|
||||
chainHead int
|
||||
hashHead [hashSize]uint32
|
||||
hashPrev [windowSize]uint32
|
||||
hashOffset int
|
||||
|
||||
// hashMatch must be able to contain hashes for the maximum match length.
|
||||
hashMatch [maxMatchLength - 1]uint32
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue