Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+12
@@ -52,6 +52,11 @@ func (d *Digest) Reset() {
|
||||
d.n = 0
|
||||
}
|
||||
|
||||
// maxAsmSize bounds the input handed to a single writeBlocks call. Assembly is
|
||||
// never preemptible, so an unbounded call holds every P in stop-the-world for
|
||||
// its duration. Whole 32-byte blocks, so Write can feed it in pieces.
|
||||
const maxAsmSize = 128 << 10 // 4096 whole 32-byte blocks
|
||||
|
||||
// Size always returns 8 bytes.
|
||||
func (d *Digest) Size() int { return 8 }
|
||||
|
||||
@@ -83,6 +88,13 @@ func (d *Digest) Write(b []byte) (n int, err error) {
|
||||
d.n = 0
|
||||
}
|
||||
|
||||
for len(b) >= maxAsmSize {
|
||||
// Assembly is not preemptible, so hashing a large buffer in one call
|
||||
// blocks every stop-the-world for the whole call. Feed it in chunks.
|
||||
writeBlocks(d, b[:maxAsmSize])
|
||||
b = b[maxAsmSize:]
|
||||
}
|
||||
|
||||
if len(b) >= 32 {
|
||||
// One or more full blocks left.
|
||||
nw := writeBlocks(d, b)
|
||||
|
||||
Reference in new issue
Block a user