• Josh Bleecher Snyder's avatar
    cmd/compile: make builds reproducible in presence of **byte and **int8 · 6f2ee0f3
    Josh Bleecher Snyder authored
    CL 39915 introduced sorting of signats by ShortString
    for reproducible builds. But ShortString treats types
    byte and uint8 identically; same for rune and uint32.
    CL 39915 attempted to compensate for this by only
    adding the underlying type (uint8) to signats in addsignat.
    
    This only works for byte and uint8. For e.g. *byte and *uint,
    both get added, and their sort order is random,
    leading to non-reproducible builds.
    
    One fix would be to add yet another type printing mode
    that doesn't eliminate byte and rune, and use it
    for sorting signats. But the formatting routines
    are complicated enough as it is.
    
    Instead, just sort first by ShortString and then by String.
    We can't just use String, because ShortString makes distinctions
    that String doesn't. ShortString is really preferred here;
    String is serving only as a backstop for handling of bytes and runes.
    
    The long series of types in the test helps increase the odds of
    failure, allowing a smaller number of iterations in the test.
    On my machine, a full test takes 700ms.
    
    Passes toolstash-check.
    
    Updates #19961
    Fixes #20272
    
    name        old alloc/op      new alloc/op      delta
    Template         37.9MB ± 0%       37.9MB ± 0%  +0.12%  (p=0.032 n=5+5)
    Unicode          28.9MB ± 0%       28.9MB ± 0%    ~     (p=0.841 n=5+5)
    GoTypes           110MB ± 0%        110MB ± 0%    ~     (p=0.841 n=5+5)
    Compiler          463MB ± 0%        463MB ± 0%    ~     (p=0.056 n=5+5)
    SSA              1.11GB ± 0%       1.11GB ± 0%  +0.02%  (p=0.016 n=5+5)
    Flate            24.7MB ± 0%       24.8MB ± 0%  +0.14%  (p=0.032 n=5+5)
    GoParser         31.1MB ± 0%       31.1MB ± 0%    ~     (p=0.421 n=5+5)
    Reflect          73.9MB ± 0%       73.9MB ± 0%    ~     (p=1.000 n=5+5)
    Tar              25.8MB ± 0%       25.8MB ± 0%  +0.15%  (p=0.016 n=5+5)
    XML              41.2MB ± 0%       41.2MB ± 0%    ~     (p=0.310 n=5+5)
    [Geo mean]       72.0MB            72.0MB       +0.07%
    
    name        old allocs/op     new allocs/op     delta
    Template           384k ± 0%         385k ± 1%    ~     (p=0.056 n=5+5)
    Unicode            343k ± 0%         344k ± 0%    ~     (p=0.548 n=5+5)
    GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.421 n=5+5)
    Compiler          4.43M ± 0%        4.44M ± 0%  +0.26%  (p=0.032 n=5+5)
    SSA               9.86M ± 0%        9.87M ± 0%  +0.10%  (p=0.032 n=5+5)
    Flate              237k ± 1%         238k ± 0%  +0.49%  (p=0.032 n=5+5)
    GoParser           319k ± 1%         320k ± 1%    ~     (p=0.151 n=5+5)
    Reflect            957k ± 0%         957k ± 0%    ~     (p=1.000 n=5+5)
    Tar                251k ± 0%         252k ± 1%  +0.49%  (p=0.016 n=5+5)
    XML                399k ± 0%         401k ± 1%    ~     (p=0.310 n=5+5)
    [Geo mean]         739k              741k       +0.26%
    
    Change-Id: Ic27995a8d374d012b8aca14546b1df9d28d30df7
    Reviewed-on: https://go-review.googlesource.com/42955
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    6f2ee0f3
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...