]> Cypherpunks repositories - gostls13.git/commit
archive/tar: optimize nanosecond parsing in parsePAXTime
author1911860538 <alxps1911@gmail.com>
Mon, 8 Sep 2025 16:19:34 +0000 (16:19 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 8 Sep 2025 17:08:20 +0000 (10:08 -0700)
commit5e6296f3f8a5fd8c07a0602435eae681002e09ad
tree5d1420cd1a452856a68e56f360a16e5043e0efb2
parentea00650784bc2909580c7decf729f668349aa939
archive/tar: optimize nanosecond parsing in parsePAXTime

Modified parsePAXTime to use a byte array for nanosecond parsing, providing a more straightforward implementation with better performance when handling decimal fraction part.
Here are benchmark results:
goos: darwin
goarch: amd64
pkg: archive/tar
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
                                │   old.txt    │               new.txt                │
                                │    sec/op    │    sec/op     vs base                │
ParsePAXTIme/NoNanos-8            20.55n ±  4%   20.45n ± 12%        ~ (p=1.000 n=10)
ParsePAXTIme/ExactNanos-8         52.42n ±  2%   42.16n ±  3%  -19.57% (p=0.000 n=10)
ParsePAXTIme/WithNanoPadding-8    99.33n ±  2%   39.58n ±  2%  -60.16% (p=0.000 n=10)
ParsePAXTIme/WithNanoTruncate-8   54.78n ±  1%   43.64n ±  4%  -20.34% (p=0.000 n=10)
ParsePAXTIme/TrailingError-8      31.87n ±  4%   17.55n ±  2%  -44.94% (p=0.000 n=10)
ParsePAXTIme/LeadingError-8       31.03n ±  2%   15.81n ±  6%  -49.03% (p=0.000 n=10)

Change-Id: If05ef512137d0115db9cb6d3ab432335230628bb
GitHub-Last-Rev: 106d25e5cfd57e0264b4510c58d09e8f80e13b3f
GitHub-Pull-Request: golang/go#73164
Reviewed-on: https://go-review.googlesource.com/c/go/+/662835
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/archive/tar/strconv.go
src/archive/tar/strconv_test.go