go/src
Russ Cox 80c98fa901 runtime/trace: record event sequence numbers explicitly
Nearly all the flaky failures we've seen in trace tests have been
due to the use of time stamps to determine relative event ordering.
This is tricky for many reasons, including:
 - different cores might not have exactly synchronized clocks
 - VMs are worse than real hardware
 - non-x86 chips have different timer resolution than x86 chips
 - on fast systems two events can end up with the same time stamp

Stop trying to make time reliable. It's clearly not going to be for Go 1.5.
Instead, record an explicit event sequence number for ordering.
Using our own counter solves all of the above problems.

The trace still contains time stamps, of course. The sequence number
is just used for ordering.

Should alleviate #10554 somewhat. Then tickDiv can be chosen to
be a useful time unit instead of having to be exact for ordering.

Separating ordering and time stamps lets the trace parser diagnose
systems where the time stamp order and actual order do not match
for one reason or another. This CL adds that check to the end of
trace.Parse, after all other sequence order-based checking.
If that error is found, we skip the test instead of failing it.
Putting the check in trace.Parse means that cmd/trace will pick
up the same check, refusing to display a trace where the time stamps
do not match actual ordering.

Using net/http's BenchmarkClientServerParallel4 on various CPU counts,
not tracing vs tracing:

name                      old time/op    new time/op    delta
ClientServerParallel4       50.4µs ± 4%    80.2µs ± 4%  +59.06%        (p=0.000 n=10+10)
ClientServerParallel4-2     33.1µs ± 7%    57.8µs ± 5%  +74.53%        (p=0.000 n=10+10)
ClientServerParallel4-4     18.5µs ± 4%    32.6µs ± 3%  +75.77%        (p=0.000 n=10+10)
ClientServerParallel4-6     12.9µs ± 5%    24.4µs ± 2%  +89.33%        (p=0.000 n=10+10)
ClientServerParallel4-8     11.4µs ± 6%    21.0µs ± 3%  +83.40%        (p=0.000 n=10+10)
ClientServerParallel4-12    14.4µs ± 4%    23.8µs ± 4%  +65.67%        (p=0.000 n=10+10)

Fixes #10512.

Change-Id: I173eecf8191e86feefd728a5aad25bf1bc094b12
Reviewed-on: https://go-review.googlesource.com/12579
Reviewed-by: Austin Clements <austin@google.com>
2015-07-29 22:32:14 +00:00
..
archive all: link to https instead of http 2015-07-11 14:36:33 +00:00
bufio bufio: Remove unneeded error initialization 2015-07-18 18:05:23 +00:00
builtin builtin: remove errant space in hyphenated adjective phrase 2015-06-28 21:41:38 +00:00
bytes Revert "bytes: document that Buffer values must not be copied" 2015-07-23 18:34:49 +00:00
cmd cmd/internal/obj/arm64: fix build 2015-07-29 21:44:27 +00:00
compress all: link to https instead of http 2015-07-11 14:36:33 +00:00
container build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
crypto crypt/rand: update docs for Linux 2015-07-26 02:57:16 +00:00
database/sql database/sql: document closing requirements for Stmts 2015-07-15 04:31:41 +00:00
debug all: cleanup usage of dashes in package documentation 2015-07-28 02:44:41 +00:00
encoding encoding/json: test style tweaks 2015-07-28 06:23:38 +00:00
errors build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
expvar expvar: swap Float sync. from mutex to atomic. 2015-04-12 23:07:50 +00:00
flag flag: add comment stating that Set is called in sequence across the command line 2015-07-16 05:33:47 +00:00
fmt fmt: restore padding for %x on byte slices and strings 2015-06-29 07:17:23 +00:00
go go/internal/gcimporter: only run compile test if go tool is available 2015-07-27 17:54:02 +00:00
hash hash/crc32: speedup crc32 of IEEE using slicingBy8 2015-06-18 18:14:24 +00:00
html html/template: add examples to package and functions 2015-07-27 16:37:33 +00:00
image image/color: fix format typo in the tests. 2015-07-16 01:41:34 +00:00
index/suffixarray build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
internal runtime/trace: record event sequence numbers explicitly 2015-07-29 22:32:14 +00:00
io io: tweak Reader comment 2015-06-29 21:17:47 +00:00
log log: fix flaky test 2015-06-18 18:08:17 +00:00
math math/big: document rounding for Rat.FloatToString 2015-07-22 19:47:19 +00:00
mime all: cleanup usage of dashes in package documentation 2015-07-28 02:44:41 +00:00
net net: make spuriousENOTAVAIL to be able to parse EADDRNOTAVAIL correctly 2015-07-28 11:52:56 +00:00
os runtime/cgo: move TMPDIR magic out of os 2015-07-27 16:05:42 +00:00
path all: link to https instead of http 2015-07-11 14:36:33 +00:00
reflect runtime, reflect: use correctly aligned stack frame sizes on arm64 2015-07-29 21:35:35 +00:00
regexp regexp: small correction to test comment 2015-06-14 17:09:13 +00:00
runtime runtime/trace: record event sequence numbers explicitly 2015-07-29 22:32:14 +00:00
sort sort: fixed small typo in comments 2015-02-08 23:38:50 +00:00
strconv strconv: add examples to package 2015-07-22 16:00:21 +00:00
strings all: link to https for golang subdomains too 2015-07-12 04:42:40 +00:00
sync sync: disable flaky WaitGroup misuse test in short mode 2015-06-29 18:44:52 +00:00
syscall syscall: warn not to use FormatMessage 2015-07-21 02:26:27 +00:00
testing runtime/trace: add new package 2015-07-22 15:47:16 +00:00
text text/template: make zero Template work again 2015-06-24 22:27:33 +00:00
time time: make it clearer how to format a fractional second 2015-07-15 05:13:05 +00:00
unicode unicode: upgrade to 8.0.0 2015-06-26 18:01:29 +00:00
unsafe unsafe: minor doc string improvements 2015-01-28 19:42:15 +00:00
all.bash
all.bat
all.rc
androidtest.bash androidtest.bash: robust cleanup in case of failure. 2015-07-17 21:12:12 +00:00
bootstrap.bash build: add bootstrap.bash for bootstrapping new systems 2015-03-02 17:51:56 +00:00
buildall.bash buildall.bash: exit 1 when make.bash fails 2015-05-17 01:40:33 +00:00
clean.bash build: fix clean scripts 2015-06-18 16:13:13 +00:00
clean.bat build: fix clean scripts 2015-06-18 16:13:13 +00:00
clean.rc build: fix clean scripts 2015-06-18 16:13:13 +00:00
iostest.bash iostest.bash: run detect.go as part of iostest 2015-04-16 12:59:54 +00:00
make.bash doc: replace references to {5..9}{g,l} with go tool compile and go tool link 2015-06-17 04:05:50 +00:00
make.bat doc: replace references to {5..9}{g,l} with go tool compile and go tool link 2015-06-17 04:05:50 +00:00
Make.dist
make.rc doc: replace references to {5..9}{g,l} with go tool compile and go tool link 2015-06-17 04:05:50 +00:00
nacltest.bash nacltest.bash: remove syscall/fstest_nacl.go after test 2015-05-02 02:48:32 +00:00
race.bash all: link to https instead of http 2015-07-11 14:36:33 +00:00
race.bat all: link to https instead of http 2015-07-11 14:36:33 +00:00
run.bash build: correct quoting of args in run.bash 2015-05-09 04:23:47 +00:00
run.bat build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
run.rc build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00