<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/encoding/binary/binary_test.go, branch json-isValidNumber</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=json-isValidNumber</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=json-isValidNumber'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2023-01-27T18:17:20Z</updated>
<entry>
<title>encoding/binary: add var NativeEndian</title>
<updated>2023-01-27T18:17:20Z</updated>
<author>
<name>cuiweixie</name>
<email>cuiweixie@gmail.com</email>
</author>
<published>2023-01-25T03:22:29Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=4b3726e99bec62e4a8b8e9cecc478b51ce0d4636'/>
<id>urn:sha1:4b3726e99bec62e4a8b8e9cecc478b51ce0d4636</id>
<content type='text'>
Updates #57237

Change-Id: I149c8b7eeac91b87b5810250f96d48ca87135807
Reviewed-on: https://go-review.googlesource.com/c/go/+/463218
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: xie cui &lt;523516579@qq.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/binary: add AppendByteOrder</title>
<updated>2022-03-02T18:21:38Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2022-02-16T00:59:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=986b04c0f12efa1c57293f147a9e734ec71f0363'/>
<id>urn:sha1:986b04c0f12efa1c57293f147a9e734ec71f0363</id>
<content type='text'>
AppendByteOrder specifies new methods for LittleEndian and BigEndian
for appending an unsigned integer to a byte slice.

The performance of AppendXXX methods are slower than PutXXX methods
since the former needs to do a few slice operations,
while the latter is essentially a single integer store.
In practice, existing usages of PutXXX performed slicing operations
around the call such that this cost was present, regardless.

name                           time/op
PutUint16-24                   0.48ns ± 2%
AppendUint16-24                1.54ns ± 1%
PutUint32-24                   0.46ns ± 2%
AppendUint32-24                0.89ns ± 1%
PutUint64-24                   0.46ns ± 2%
AppendUint64-24                0.89ns ± 1%
LittleEndianPutUint16-24       0.47ns ± 2%
LittleEndianAppendUint16-24    1.54ns ± 1%
LittleEndianPutUint32-24       0.45ns ± 3%
LittleEndianAppendUint32-24    0.92ns ± 2%
LittleEndianPutUint64-24       0.46ns ± 3%
LittleEndianAppendUint64-24    0.95ns ± 4%

Fixes #50601

Change-Id: I33d2bbc93a3ce01a9269feac33a2432bc1166ead
Reviewed-on: https://go-review.googlesource.com/c/go/+/386017
Trust: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Trust: Josh Bleecher Snyder &lt;josharian@gmail.com&gt;
Reviewed-by: Josh Bleecher Snyder &lt;josharian@gmail.com&gt;
Run-TryBot: Joseph Tsai &lt;joetsai@digital-static.net&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>all: gofmt -w -r 'interface{} -&gt; any' src</title>
<updated>2021-12-13T18:45:54Z</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2021-12-01T17:15:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=2580d0e08d5e9f979b943758d3c49877fb2324cb'/>
<id>urn:sha1:2580d0e08d5e9f979b943758d3c49877fb2324cb</id>
<content type='text'>
And then revert the bootstrap cmd directories and certain testdata.
And adjust tests as needed.

Not reverting the changes in std that are bootstrapped,
because some of those changes would appear in API docs,
and we want to use any consistently.
Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories
when preparing the bootstrap copy.

A few files changed as a result of running gofmt -w
not because of interface{} -&gt; any but because they
hadn't been updated for the new //go:build lines.

Fixes #49884.

Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09
Reviewed-on: https://go-review.googlesource.com/c/go/+/368254
Trust: Russ Cox &lt;rsc@golang.org&gt;
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
Reviewed-by: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>all: update references to symbols moved from io/ioutil to io</title>
<updated>2020-10-20T18:41:18Z</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2020-10-16T04:49:02Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=1b09d430678d4a6f73b2443463d11f75851aba8a'/>
<id>urn:sha1:1b09d430678d4a6f73b2443463d11f75851aba8a</id>
<content type='text'>
The old ioutil references are still valid, but update our code
to reflect best practices and get used to the new locations.

Code compiled with the bootstrap toolchain
(cmd/asm, cmd/dist, cmd/compile, debug/elf)
must remain Go 1.4-compatible and is excluded.
Also excluded vendored code.

For #41190.

Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/263142
Trust: Russ Cox &lt;rsc@golang.org&gt;
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
TryBot-Result: Go Bot &lt;gobot@golang.org&gt;
Reviewed-by: Emmanuel Odeke &lt;emm.odeke@gmail.com&gt;
</content>
</entry>
<entry>
<title>encoding/binary: remove TODO in Write and add benchmarks</title>
<updated>2020-09-23T03:14:03Z</updated>
<author>
<name>zhouzhongyuan</name>
<email>zhouzhongyuan96@gmail.com</email>
</author>
<published>2020-08-05T07:08:54Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=83bc1ed3165e31d1fbeb1e6594373dc11b6ae0a4'/>
<id>urn:sha1:83bc1ed3165e31d1fbeb1e6594373dc11b6ae0a4</id>
<content type='text'>
Benchmarks:
goos: linux
goarch: amd64
BenchmarkReadSlice1000Uint8s-8           4097088               296 ns/op        3381.06 MB/s
BenchmarkWriteSlice1000Uint8s-8          4372588               271 ns/op        3694.96 MB/s

Change-Id: I5b6ef0da5052e3381ee9c714bbff541c11ed0259
Reviewed-on: https://go-review.googlesource.com/c/go/+/246837
Run-TryBot: Alberto Donizetti &lt;alb.donizetti@gmail.com&gt;
TryBot-Result: Go Bot &lt;gobot@golang.org&gt;
Reviewed-by: Alberto Donizetti &lt;alb.donizetti@gmail.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
Trust: Alberto Donizetti &lt;alb.donizetti@gmail.com&gt;
</content>
</entry>
<entry>
<title>encoding/binary: add float support to fast path</title>
<updated>2019-11-08T18:35:59Z</updated>
<author>
<name>Martin Garton</name>
<email>garton@gmail.com</email>
</author>
<published>2019-09-30T09:27:38Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=7714dcacbca1961543fbad0c8bc2a2afc7baaaee'/>
<id>urn:sha1:7714dcacbca1961543fbad0c8bc2a2afc7baaaee</id>
<content type='text'>
This adds float type support to the main switch blocks in Read and
Write, instead of falling back to reflection. This gives a considerable
speedup for the float types:

ReadFloats-8                 129ns ± 9%       70ns ± 8%   -46.02%  (p=0.001 n=7+7)
WriteFloats-8                131ns ± 6%       86ns ±11%   -34.59%  (p=0.001 n=7+7)
ReadSlice1000Float32s-8     14.6µs ±14%      4.8µs ±12%   -67.29%  (p=0.001 n=7+7)
WriteSlice1000Float32s-8    16.4µs ±20%      4.7µs ± 8%   -71.01%  (p=0.001 n=7+7)

Change-Id: I0be99d068b07d10dd6eb1137b45eff6f7c216b87
GitHub-Last-Rev: 4ff326e99ca35977d819f0ba29c10d9efc7e811c
GitHub-Pull-Request: golang/go#31803
Reviewed-on: https://go-review.googlesource.com/c/go/+/174959
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>encoding/binary: make Read return an error when data is not a pointer</title>
<updated>2019-11-08T18:00:31Z</updated>
<author>
<name>Udalov Max</name>
<email>re.udalov@gmail.com</email>
</author>
<published>2019-07-03T20:31:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=c444ec308506463bd4ab3226c6aab55746347780'/>
<id>urn:sha1:c444ec308506463bd4ab3226c6aab55746347780</id>
<content type='text'>
Make binary.Read return an error when passed `data` argument is not
a pointer to a fixed-size value or a slice of fixed-size values.

Fixes #32927

Change-Id: I04f48be55fe9b0cc66c983d152407d0e42cbcd95
Reviewed-on: https://go-review.googlesource.com/c/go/+/184957
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>encoding/binary: cache struct sizes to speed up Read and Write</title>
<updated>2019-11-01T20:16:01Z</updated>
<author>
<name>Lorenz Bauer</name>
<email>lmb@cloudflare.com</email>
</author>
<published>2019-11-01T10:39:35Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=c9d89f6bacd66d4765cf36d2a4b121392921c5ed'/>
<id>urn:sha1:c9d89f6bacd66d4765cf36d2a4b121392921c5ed</id>
<content type='text'>
A majority of work is spent in dataSize when en/decoding the same
struct over and over again. This wastes a lot of work, since
the result doesn't change for a given reflect.Value.

Cache the result of the function for structs, so that subsequent
calls to dataSize can avoid doing work.

    name         old time/op    new time/op     delta
    ReadStruct     1.00µs ± 1%     0.37µs ± 1%   -62.99%  (p=0.029 n=4+4)
    WriteStruct    1.00µs ± 3%     0.37µs ± 1%   -62.69%  (p=0.008 n=5+5)

    name         old speed      new speed       delta
    ReadStruct   75.1MB/s ± 1%  202.9MB/s ± 1%  +170.16%  (p=0.029 n=4+4)
    WriteStruct  74.8MB/s ± 3%  200.4MB/s ± 1%  +167.96%  (p=0.008 n=5+5)

Fixes #34471

Change-Id: Ic5d987ca95f1197415ef93643a0af6fc1224fdf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/199539
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
Run-TryBot: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>cmd/compile: add rules to improve consecutive byte loads and stores on ppc64le</title>
<updated>2017-11-03T18:46:59Z</updated>
<author>
<name>Lynn Boger</name>
<email>laboger@linux.vnet.ibm.com</email>
</author>
<published>2017-10-30T16:30:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=bb1fd3b5ff10eb9ad1a40b5bf7c7f35bd20e626f'/>
<id>urn:sha1:bb1fd3b5ff10eb9ad1a40b5bf7c7f35bd20e626f</id>
<content type='text'>
This adds new rules to recognize consecutive byte loads and
stores and lowers them to loads and stores such as lhz, lwz, ld,
sth, stw, std. This change only covers the little endian cases
on little endian machines, such as is found in encoding/binary
UintXX or PutUintXX for little endian. Big endian will be done
later.

Updates were also made to binary_test.go to allow the benchmark
for Uint and PutUint to actually use those functions because
the way they were written, those functions were being
optimized out.

Testcases were also added to cmd/compile/internal/gc/asm_test.go.

Updates #22496

The following improvement can be found in golang.org/x/crypto

poly1305:

Benchmark64-16              142           114           -19.72%
Benchmark1K-16              1717          1424          -17.06%
Benchmark64Unaligned-16     142           113           -20.42%
Benchmark1KUnaligned-16     1721          1428          -17.02%

chacha20poly1305:

BenchmarkChacha20Poly1305Open_64-16     1012       885   -12.55%
BenchmarkChacha20Poly1305Seal_64-16     971        836   -13.90%
BenchmarkChacha20Poly1305Open_1350-16   11113      9539  -14.16%
BenchmarkChacha20Poly1305Seal_1350-16   11013      9392  -14.72%
BenchmarkChacha20Poly1305Open_8K-16     61074      53431 -12.51%
BenchmarkChacha20Poly1305Seal_8K-16     61214      54806 -10.47%

Other improvements of around 10% found in crypto/tls.

Results after updating encoding/binary/binary_test.go:

BenchmarkLittleEndianPutUint64-16     1.87      0.93      -50.27%
BenchmarkLittleEndianPutUint32-16     1.19      0.93      -21.85%
BenchmarkLittleEndianPutUint16-16     1.16      1.03      -11.21%

Change-Id: I7bbe2fbcbd11362d58662fecd907a0c07e6ca2fb
Reviewed-on: https://go-review.googlesource.com/74410
Run-TryBot: Lynn Boger &lt;laboger@linux.vnet.ibm.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Michael Munday &lt;mike.munday@ibm.com&gt;
</content>
</entry>
<entry>
<title>cmd/compile/internal/ssa: combine 2 byte loads + shifts into word load + rolw 8 on AMD64</title>
<updated>2017-02-14T22:17:08Z</updated>
<author>
<name>Kirill Smelkov</name>
<email>kirr@nexedi.com</email>
</author>
<published>2016-12-01T20:43:21Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=4477fd097fcc16c6d2703ec6228f47c9af030655'/>
<id>urn:sha1:4477fd097fcc16c6d2703ec6228f47c9af030655</id>
<content type='text'>
... and same for stores. This does for binary.BigEndian.Uint16() what
was already done for Uint32 and Uint64 with BSWAP in 10f75748 (CL 32222).

Here is how generated code changes e.g. for the following function
(omitting saying the same prologue/epilogue):

	func get16(b [2]byte) uint16 {
		return binary.BigEndian.Uint16(b[:])
	}

"".get16 t=1 size=21 args=0x10 locals=0x0

	// before
        0x0000 00000 (x.go:15)  MOVBLZX "".b+9(FP), AX
        0x0005 00005 (x.go:15)  MOVBLZX "".b+8(FP), CX
        0x000a 00010 (x.go:15)  SHLL    $8, CX
        0x000d 00013 (x.go:15)  ORL     CX, AX

	// after
	0x0000 00000 (x.go:15)	MOVWLZX	"".b+8(FP), AX
	0x0005 00005 (x.go:15)	ROLW	$8, AX

encoding/binary is speedup overall a bit:

name                    old time/op    new time/op    delta
ReadSlice1000Int32s-4     4.83µs ± 0%    4.83µs ± 0%     ~     (p=0.206 n=4+5)
ReadStruct-4              1.29µs ± 2%    1.28µs ± 1%   -1.27%  (p=0.032 n=4+5)
ReadInts-4                 384ns ± 1%     385ns ± 1%     ~     (p=0.968 n=4+5)
WriteInts-4                534ns ± 3%     526ns ± 0%   -1.54%  (p=0.048 n=4+5)
WriteSlice1000Int32s-4    5.02µs ± 0%    5.11µs ± 3%     ~     (p=0.175 n=4+5)
PutUint16-4               0.59ns ± 0%    0.49ns ± 2%  -16.95%  (p=0.016 n=4+5)
PutUint32-4               0.52ns ± 0%    0.52ns ± 0%     ~     (all equal)
PutUint64-4               0.53ns ± 0%    0.53ns ± 0%     ~     (all equal)
PutUvarint32-4            19.9ns ± 0%    19.9ns ± 1%     ~     (p=0.556 n=4+5)
PutUvarint64-4            54.5ns ± 1%    54.2ns ± 0%     ~     (p=0.333 n=4+5)

name                    old speed      new speed      delta
ReadSlice1000Int32s-4    829MB/s ± 0%   828MB/s ± 0%     ~     (p=0.190 n=4+5)
ReadStruct-4            58.0MB/s ± 2%  58.7MB/s ± 1%   +1.30%  (p=0.032 n=4+5)
ReadInts-4              78.0MB/s ± 1%  77.8MB/s ± 1%     ~     (p=0.968 n=4+5)
WriteInts-4             56.1MB/s ± 3%  57.0MB/s ± 0%     ~     (p=0.063 n=4+5)
WriteSlice1000Int32s-4   797MB/s ± 0%   783MB/s ± 3%     ~     (p=0.190 n=4+5)
PutUint16-4             3.37GB/s ± 0%  4.07GB/s ± 2%  +20.83%  (p=0.016 n=4+5)
PutUint32-4             7.73GB/s ± 0%  7.72GB/s ± 0%     ~     (p=0.556 n=4+5)
PutUint64-4             15.1GB/s ± 0%  15.1GB/s ± 0%     ~     (p=0.905 n=4+5)
PutUvarint32-4           201MB/s ± 0%   201MB/s ± 0%     ~     (p=0.905 n=4+5)
PutUvarint64-4           147MB/s ± 1%   147MB/s ± 0%     ~     (p=0.286 n=4+5)

( "a bit" only because most of the time is spent in reflection-like things
  there, not actual bytes decoding. Even for direct PutUint16 benchmark the
  looping adds overhead and lowers visible benefit. For code-generated encoders /
  decoders actual effect is more than 20% )

Adding Uint32 and Uint64 raw benchmarks too for completeness.

NOTE I had to adjust load-combining rule for bswap case to match first 2 bytes
loads as result of "2-bytes load+shift" -&gt; "loadw + rorw 8" rewrite. Reason is:
for loads+shift, even e.g. into uint16 var

	var b []byte
	var v uin16
	v = uint16(b[1]) | uint16(b[0])&lt;&lt;8

the compiler eventually generates L(ong) shift - SHLLconst [8], probably
because it is more straightforward / other reasons to work on the whole
register. This way 2 bytes rewriting rule is using SHLLconst (not SHLWconst) in
its pattern, and then it always gets matched first, even if 2-byte rule comes
syntactically after 4-byte rule in AMD64.rules because 4-bytes rule seemingly
needs more applyRewrite() cycles to trigger. If 2-bytes rule gets matched for
inner half of

	var b []byte
	var v uin32
	v = uint32(b[3]) | uint32(b[2])&lt;&lt;8 | uint32(b[1])&lt;&lt;16 | uint32(b[0])&lt;&lt;24

and we keep 4-byte load rule unchanged, the result will be MOVW + RORW $8 and
then series of byte loads and shifts - not one MOVL + BSWAPL.

There is no such problem for stores: there compiler, since it probably knows
store destination is 2 bytes wide, uses SHRWconst 8 (not SHRLconst 8) and thus
2-byte store rule is not a subset of rule for 4-byte stores.

Fixes #17151  (int16 was last missing piece there)

Change-Id: Idc03ba965bfce2b94fef456b02ff6742194748f6
Reviewed-on: https://go-review.googlesource.com/34636
Reviewed-by: Ilya Tocar &lt;ilya.tocar@intel.com&gt;
Run-TryBot: Ilya Tocar &lt;ilya.tocar@intel.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</content>
</entry>
</feed>
