]> Cypherpunks repositories - gostls13.git/commit
runtime: replace traceBuf slice with index
authorAustin Clements <austin@google.com>
Tue, 10 Nov 2015 19:58:51 +0000 (14:58 -0500)
committerAustin Clements <austin@google.com>
Wed, 11 Nov 2015 17:37:31 +0000 (17:37 +0000)
commitf5c42cf88e8c9d75d1738bc2eae81b717071b9d0
tree1d1d933e0fde97b7e6a3ca5848998dd8dcdb3957
parent2be1ed80c509ca9768acf729a4ad541ccb4d3dd0
runtime: replace traceBuf slice with index

Currently traceBuf keeps track of where it is in the trace buffer by
also maintaining a slice that points in to this buffer with an initial
length of 0 and a cap of the length of the array. All writes to this
buffer are done by appending to the slice (as long as the bounds
checks are right, it will never overflow and the append won't allocate
a new slice).

Each of these appends generates a write barrier. As long as we never
overflow the buffer, this write barrier won't fire, but this wreaks
havoc with eliminating write barriers from the tracing code. If we
were to overflow the buffer, this would both allocate and invoke a
write barrier, both things that are dicey at best to do in many of the
contexts tracing happens. It also wastes space in the traceBuf and
leads to more complex code and more complex generated code.

Replace this slice trick with keeping track of a simple array
position.

Updates #10600.

Change-Id: I0a63eecec1992e195449f414ed47653f66318d0e
Reviewed-on: https://go-review.googlesource.com/16814
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/trace.go