Descriptioncmd/gc: optimize memclr of slices and arrays
[TODO: Use samesafeexpr from CL 159960043 instead of checking that a is an ONAME?]
[TODO: Add write barriers as needed. writebarrierfat, CL 2061]
[TODO: Add memset]
[TODO: Respect -N compiler flag.]
Update issue 5373
Recognize loops of the form
for i := range a {
a[i] = [zero val]
}
and replace them with calls to memclr. This occurs in the stdlib in three non-test functions:
image/draw drawPaletted
compress/flate (*huffmanBitWriter).reset
math/big net.clear
memset is more complicated and is left for future work. Also for future work is accepting any range expression whose evaluation is free from side-effects; see issue 7622 for a syntactic approach to that.
Significant benchmark changes:
runtime
BenchmarkGoMemclr5 3.29 2.98 -9.42%
BenchmarkGoMemclr16 13.6 3.25 -76.10%
BenchmarkGoMemclr64 50.2 3.55 -92.93%
BenchmarkGoMemclr256 154 6.02 -96.09%
compress/flate
BenchmarkEncodeTwainDefault1e4 778746 754950 -3.06%
BenchmarkEncodeTwainDefault1e5 10782677 10463178 -2.96%
BenchmarkEncodeTwainDefault1e6 114453656 112236189 -1.94%
BenchmarkEncodeDigitsDefault1e5 12598635 12365839 -1.85%
BenchmarkDecodeTwainSpeed1e4 203180 199583 -1.77%
BenchmarkDecodeTwainSpeed1e6 15289086 15026232 -1.72%
BenchmarkEncodeTwainSpeed1e6 28794254 28307233 -1.69%
BenchmarkDecodeTwainSpeed1e5 1581313 1556212 -1.59%
BenchmarkDecodeDigitsCompress1e6 14688734 14458648 -1.57%
BenchmarkEncodeTwainSpeed1e4 539456 547890 +1.56%
BenchmarkDecodeTwainCompress1e6 12198494 12031018 -1.37%
BenchmarkDecodeTwainCompress1e5 1300425 1282819 -1.35%
BenchmarkDecodeDigitsDefault1e6 14437604 14242762 -1.35%
BenchmarkDecodeTwainDefault1e6 12278837 12131759 -1.20%
BenchmarkEncodeDigitsCompress1e5 12640931 12490414 -1.19%
Patch Set 1 #Patch Set 2 : diff -r e5c87cefb57fffc5767209542be5c4e58123e3c6 https://code.google.com/p/go #Patch Set 3 : diff -r e5c87cefb57fffc5767209542be5c4e58123e3c6 https://code.google.com/p/go #Patch Set 4 : diff -r e5c87cefb57fffc5767209542be5c4e58123e3c6 https://code.google.com/p/go #Patch Set 5 : diff -r e5c87cefb57fffc5767209542be5c4e58123e3c6 https://code.google.com/p/go #
|