This backports !5223 (merged) and !5226 (merged) to the 15-7-stable
branch.
In 7c5bbf61, the addition of the ProtoFormat
field to ObjectHash
increased the number of bytes in the structure from 64 to 72. As a
result, requestQueue
now looks like:
type requestQueue struct {
objectHash git.ObjectHash // 72 bytes
outstandingRequests int64 // 8 bytes
closed int32 // 4 bytes
isReadingObject int32 // 4 bytes
isObjectQueue bool // 1 byte
stdout *bufio.Reader // 8 bytes
stdin *bufio.Writer // 8 bytes
trace *trace // 8 bytes
}
Previously requestQueue
totaled 112 bytes, which is 64-bit
aligned. However, the addition of this new field in objectHash
pushes the structure to 113 raw bytes. On a Raspberry Pi system, the
Go compiler only guarantees 32-bit alignment, so we end up with a
structure that is 116 bytes, which isn't 64-bit aligned.
Moving outstandingRequests
to be first in the struct isn't
enough. As https://github.com/golang/go/issues/11891#issue-97544684
says, in an array of structs, only the first element of a structure
may be automatically 64-bit aligned. It depends if the size of each
element, plus padding, is a multiple of 8.
To fix this mess, we now split these atomic counters in its own structure and add a test to ensure that it is 64-bit aligned.
Relates to #4701 (closed)
Changelog: fixed