Commit Graph

740 Commits

Author SHA1 Message Date
Thomas Pelletier 8f6d0d8be7 Specialize map[string]iface when unmarshaling kvs
name                               old time/op    new time/op    delta
UnmarshalDataset/config-8            12.3ms ± 0%    10.9ms ± 0%  -11.36%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            55.2ms ± 0%    55.4ms ± 1%     ~     (p=0.690 n=5+5)
UnmarshalDataset/citm_catalog-8      16.5ms ± 1%    15.7ms ± 0%   -4.43%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           7.01ms ± 1%    6.63ms ± 0%   -5.34%  (p=0.008 n=5+5)
UnmarshalDataset/code-8              52.0ms ± 0%    48.7ms ± 2%   -6.43%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            119µs ± 0%     110µs ± 3%   -6.81%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8     432ns ± 1%     431ns ± 1%     ~     (p=0.222 n=5+5)
Unmarshal/SimpleDocument/map-8        573ns ± 1%     540ns ± 1%   -5.64%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8     33.7µs ± 0%    33.6µs ± 0%     ~     (p=0.310 n=5+5)
Unmarshal/ReferenceFile/map-8        44.2µs ± 1%    41.7µs ± 1%   -5.63%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8          7.28µs ± 1%    6.74µs ± 1%   -7.42%  (p=0.008 n=5+5)
[Geo mean]                            292µs          277µs        -4.91%

name                               old speed      new speed      delta
UnmarshalDataset/config-8          85.2MB/s ± 0%  96.1MB/s ± 0%  +12.82%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8          39.9MB/s ± 0%  39.8MB/s ± 1%     ~     (p=0.690 n=5+5)
UnmarshalDataset/citm_catalog-8    33.9MB/s ± 1%  35.5MB/s ± 0%   +4.64%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8         63.1MB/s ± 1%  66.6MB/s ± 0%   +5.65%  (p=0.008 n=5+5)
UnmarshalDataset/code-8            51.6MB/s ± 0%  55.1MB/s ± 2%   +6.88%  (p=0.008 n=5+5)
UnmarshalDataset/example-8         68.3MB/s ± 0%  73.4MB/s ± 3%   +7.34%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8  25.4MB/s ± 1%  25.5MB/s ± 1%     ~     (p=0.246 n=5+5)
Unmarshal/SimpleDocument/map-8     19.2MB/s ± 1%  20.4MB/s ± 1%   +5.99%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8    156MB/s ± 0%   156MB/s ± 0%     ~     (p=0.310 n=5+5)
Unmarshal/ReferenceFile/map-8       119MB/s ± 1%   126MB/s ± 1%   +5.97%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8        75.0MB/s ± 1%  81.0MB/s ± 1%   +8.01%  (p=0.008 n=5+5)
[Geo mean]                         56.1MB/s       59.0MB/s        +5.17%

name                               old alloc/op   new alloc/op   delta
UnmarshalDataset/config-8            5.26MB ± 0%    4.75MB ± 0%   -9.66%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            83.0MB ± 0%    83.0MB ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8      34.7MB ± 0%    34.3MB ± 0%   -1.13%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           12.7MB ± 0%    12.5MB ± 0%   -1.44%  (p=0.008 n=5+5)
UnmarshalDataset/code-8              15.3MB ± 0%    13.9MB ± 0%   -9.27%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            186kB ± 0%     182kB ± 0%   -2.20%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      805B ± 0%      805B ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8       1.13kB ± 0%    1.12kB ± 0%   -1.41%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8     20.9kB ± 0%    20.9kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8        36.4kB ± 0%    35.4kB ± 0%     ~     (p=0.079 n=4+5)
Unmarshal/HugoFrontMatter-8          7.20kB ± 0%    6.98kB ± 0%   -3.11%  (p=0.008 n=5+5)
[Geo mean]                            312kB          303kB        -2.86%

name                               old allocs/op  new allocs/op  delta
UnmarshalDataset/config-8              189k ± 0%      157k ± 0%  -16.80%  (p=0.029 n=4+4)
UnmarshalDataset/canada-8              782k ± 0%      782k ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8        191k ± 0%      167k ± 0%  -12.75%  (p=0.000 n=4+5)
UnmarshalDataset/twitter-8            56.9k ± 0%     45.5k ± 0%  -20.02%  (p=0.016 n=5+4)
UnmarshalDataset/code-8                626k ± 0%      537k ± 0%  -14.22%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            1.36k ± 0%     1.11k ± 0%  -18.53%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      9.00 ± 0%      9.00 ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8         13.0 ± 0%      12.0 ± 0%   -7.69%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8        183 ± 0%       183 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8           526 ± 0%       466 ± 0%  -11.41%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8             126 ± 0%       112 ± 0%  -11.11%  (p=0.008 n=5+5)
[Geo mean]                            3.73k          3.34k       -10.51%
2022-04-15 17:41:18 -04:00
Thomas Pelletier 3c4b709fed Specialize navigating map[string]interface{}
This is a common type. Specializing it to reduce the use of reflection
yields better performance.

Similar to https://github.com/pelletier/go-toml/pull/669, there is a lot
to explore there.

name                               old time/op    new time/op    delta
UnmarshalDataset/config-8            13.3ms ± 0%    12.3ms ± 0%   -7.45%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            55.7ms ± 0%    55.2ms ± 0%   -0.88%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8      16.6ms ± 1%    16.5ms ± 1%   -0.97%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           7.10ms ± 1%    7.01ms ± 1%   -1.28%  (p=0.016 n=5+5)
UnmarshalDataset/code-8              63.8ms ± 0%    52.0ms ± 0%  -18.45%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            121µs ± 0%     119µs ± 0%   -2.13%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8     438ns ± 1%     432ns ± 1%   -1.40%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-8        594ns ± 2%     573ns ± 1%   -3.56%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8     34.3µs ± 1%    33.7µs ± 0%   -1.95%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-8        48.6µs ± 0%    44.2µs ± 1%   -9.22%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8          7.88µs ± 1%    7.28µs ± 1%   -7.66%  (p=0.008 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-8          78.9MB/s ± 0%  85.2MB/s ± 0%   +8.05%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8          39.5MB/s ± 0%  39.9MB/s ± 0%   +0.89%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8    33.6MB/s ± 1%  33.9MB/s ± 1%   +0.98%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8         62.3MB/s ± 1%  63.1MB/s ± 1%   +1.30%  (p=0.016 n=5+5)
UnmarshalDataset/code-8            42.1MB/s ± 0%  51.6MB/s ± 0%  +22.62%  (p=0.008 n=5+5)
UnmarshalDataset/example-8         66.9MB/s ± 0%  68.3MB/s ± 0%   +2.18%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8  25.1MB/s ± 1%  25.4MB/s ± 1%   +1.43%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-8     18.5MB/s ± 2%  19.2MB/s ± 1%   +3.70%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8    153MB/s ± 1%   156MB/s ± 0%   +1.99%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-8       108MB/s ± 0%   119MB/s ± 1%  +10.16%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8        69.3MB/s ± 1%  75.0MB/s ± 1%   +8.30%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op   delta
UnmarshalDataset/config-8            5.86MB ± 0%    5.26MB ± 0%  -10.36%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            83.0MB ± 0%    83.0MB ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8      34.7MB ± 0%    34.7MB ± 0%   -0.04%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           12.7MB ± 0%    12.7MB ± 0%     ~     (p=0.548 n=5+5)
UnmarshalDataset/code-8              22.2MB ± 0%    15.3MB ± 0%  -30.76%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            186kB ± 0%     186kB ± 0%   -0.04%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      805B ± 0%      805B ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8       1.13kB ± 0%    1.13kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-8     20.9kB ± 0%    20.9kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8        38.2kB ± 0%    36.4kB ± 0%   -4.86%  (p=0.029 n=4+4)
Unmarshal/HugoFrontMatter-8          7.44kB ± 0%    7.20kB ± 0%   -3.23%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op  delta
UnmarshalDataset/config-8              227k ± 0%      189k ± 0%  -16.74%  (p=0.029 n=4+4)
UnmarshalDataset/canada-8              782k ± 0%      782k ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8        192k ± 0%      191k ± 0%   -0.49%  (p=0.000 n=5+4)
UnmarshalDataset/twitter-8            56.9k ± 0%     56.9k ± 0%   -0.00%  (p=0.032 n=5+5)
UnmarshalDataset/code-8               1.05M ± 0%     0.63M ± 0%  -40.52%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            1.36k ± 0%     1.36k ± 0%   -0.15%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      9.00 ± 0%      9.00 ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8         13.0 ± 0%      13.0 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-8        183 ± 0%       183 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8           642 ± 0%       526 ± 0%  -18.07%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8             141 ± 0%       126 ± 0%  -10.64%  (p=0.008 n=5+5)
2022-04-15 17:20:24 -04:00
Thomas Pelletier adacebd8c7 Update benchmarks in README (#756) v2.0.0-beta.8 2022-04-10 22:24:19 -04:00
Thomas Pelletier 8bbb673431 Fuzzing setup and fixes (#755)
* encode: fix localdate formatting
* encode: fix empty key marshaling
* encode: fix invalid quotation of time.Time
* encode: ensure control chars are escaped
* decode: always use UTC for zero tz
* encode: check for invalid characters in keys
* encode: always construct map for empty array tables
* fuzz: add go 1.18 fuzz test
* encode: handle NaNs
* encode: allow new lines in quoted keys
* encode: never emit table inside array
* encode: don't capitalize inf
2022-04-10 21:37:12 -04:00
Thomas Pelletier 2377ac4bc0 encode: fix embedded interfaces (#753)
Resolve marshaling regression when handling an embedded interface in a
struct.

Fixes #752
2022-04-08 09:25:54 -04:00
Thomas Pelletier f5cc8c49eb decoder: remove mention of UnmarshalText in errors (#751)
Fixes #737
v2.0.0-beta.7
2022-04-07 21:58:19 -04:00
Thomas Pelletier 89d7b412d8 decode: allow subtables to be defined later (#750)
Fixes #739
2022-04-07 21:49:16 -04:00
Thomas Pelletier 88a8aecdd4 tools: display error context when it exists (#749)
For example when failing to decode toml, display the context around the
error and the location of the problem.
2022-04-07 20:33:09 -04:00
Thomas Pelletier 9804fc57e0 decoder: support \e escape sequence (#748) 2022-04-07 20:18:30 -04:00
Thomas Pelletier 068279f13b encode: respect stdlib rules for embedded structs (#747) v2.0.0-beta.6 2022-04-07 19:51:09 -04:00
Thomas Pelletier b9edbeb611 Update testify dependency (#746) 2022-03-30 15:10:57 -04:00
Thomas Pelletier a97c9317d4 Go 1.18 (#745) 2022-03-23 10:26:12 -04:00
Gregory Oschwald 3229a0abfb Decode: convert table key to correct type (#741)
Fixes #740.
2022-03-02 09:24:01 -05:00
Thomas Pelletier 3f5d8a6b06 Mention removal of go-toml/query (#736)
Fixes #722
2022-01-07 18:58:33 -05:00
Cameron Moore 146f70ea8a Decode: use cleaned byte slice throughout parseFloat (#735)
Fixes #734
2022-01-06 14:34:27 -05:00
Thomas Pelletier e83cf535f5 Decoder: rename SetStrict to DisallowUnknownFields (#731) 2022-01-02 14:32:34 -05:00
Thomas Pelletier c3ba3ef97a readme: add docker image 2022-01-01 09:53:14 -05:00
Thomas Pelletier 7ee3c8ff25 build: login to github repository 2022-01-01 09:24:52 -05:00
Thomas Pelletier 1e85aa6d78 build: add contents permissions 2021-12-31 20:47:50 -05:00
Thomas Pelletier 46fa3225e2 build: allows the token to write packages 2021-12-31 20:25:11 -05:00
Thomas Pelletier 4d51831dab build: replace grc.io with ghcr.io 2021-12-31 20:10:36 -05:00
Thomas Pelletier 5a1a96cb2d build: pass the github token to goreleaser 2021-12-31 20:03:18 -05:00
Thomas Pelletier ea9040ae83 build: change workflow reference to v2 2021-12-31 19:57:41 -05:00
Thomas Pelletier 2373685f1e Docker + goreleaser (#729) 2021-12-31 19:55:31 -05:00
Thomas Pelletier f1391952d4 Update and move testsuite to internal package (#730)
* Regenerate test suite

* Move test suite to /internal
2021-12-31 18:52:26 -05:00
Thomas Pelletier 4a73a200ed Clean up tools godoc 2021-12-31 15:56:40 -05:00
Thomas Pelletier 4807229e94 tomll: port to v2 (#727)
Fixes #721
2021-12-31 15:40:18 -05:00
Thomas Pelletier d8ddc00c61 jsontoml: port to v2 (#726)
Fixes #719
2021-12-31 14:40:20 -05:00
Thomas Pelletier 82f8dad811 tomljson: port to v2 (#725) 2021-12-31 13:25:53 -05:00
Thomas Pelletier 75db1016e8 Remove extra words from CONTRIBUTING 2021-12-29 10:26:22 -05:00
Thomas Pelletier de6d715bd2 Update CONTRIBUTING.md 2021-12-29 10:25:28 -05:00
Thomas Pelletier 3ab2fc2b87 Update release proces documentation 2021-12-29 10:24:01 -05:00
Thomas Pelletier 1b1dd3d6d5 Exclude testing PRs from release notes v2.0.0-beta.5 2021-12-29 09:53:43 -05:00
Cameron Moore 128b7a8bfb Decode: check buffer length before parsing simple key (#717)
Fixes #714
2021-12-29 08:58:42 -05:00
Cameron Moore 892df5c28e Decode: fix index out of range bug (#716)
Fixes #715
2021-12-29 08:49:33 -05:00
Thomas Pelletier d58eb50ebf Doc: clarify errors returned by Decode (#713)
Fixes #625
2021-12-26 20:04:09 +01:00
Thomas Pelletier 535fc65c5f Fix link in README 2021-12-26 19:49:35 +01:00
Thomas Pelletier f158d7d278 Readme: document more differences with v1 (#712)
* Readme: document more changes with v1

Closes #552
2021-12-26 19:47:03 +01:00
Thomas Pelletier 5fd6e9cce0 Encode: add comment struct tag (#711)
Similar to v1, add a `comment` struct that that makes the encoder emit a comment
before the annotated element, if permitted. Unlike v1, comments are compact by
default (and cannot be changed).

Fixes #595.
2021-12-26 18:29:46 +01:00
Thomas Pelletier 8ce5c3d78f Decoder: time allows extra precision (#710)
As discussed[1], this change allows times to provide precision beyond the
nanosecond (nine digits fractional part). Extra precision is truncated according
to the TOML specificiation.

[1]: https://github.com/pelletier/go-toml/discussions/707
2021-12-26 17:05:10 +01:00
Thomas Pelletier 177b4a5e53 Decode: allow \r\n as line whitespace before \ (#709)
Fixes #708
2021-12-26 16:38:15 +01:00
Cameron Moore 5cbdea6192 decode: fix maximum time offset values (#706)
According to RFC3339 section 5.6, the maximum time offset values for
hours and minutes is 23 and 59, respectively.
2021-12-22 10:29:52 +01:00
Thomas Pelletier 696dd25c17 Decoder: disallow modification of existing table (#704)
Fixes #703
2021-12-15 11:05:27 -05:00
Thomas Pelletier facb2b13e8 Decoder: prevent modification of inline tables (#702)
Fixes #701
2021-12-12 09:43:42 -05:00
Cameron Moore 8bbb519477 Decode: ensure signed exponents don't start with an underscore (#699) 2021-12-05 20:02:19 -05:00
Cameron Moore b37e11d74d Decode: allow maximum seconds value of 60 (#700)
RFC3339 allows seconds to be 60 when adding leap seconds
2021-12-05 20:00:42 -05:00
Cameron Moore 6cd86876b8 Decode: ensure signed numbers don't start with an underscore (#698) 2021-12-04 16:56:48 -05:00
Cameron Moore f53bc740c1 Decode: restrict timezone offset values (#696)
Don't allow hours greater than 24 and minutes greater than 60 per RFC
3339.
2021-12-02 18:59:32 -05:00
Thomas Pelletier 9bf9be681e Decoder: check for invalid chars in timezone (#695)
Fixes #694
2021-12-02 09:00:20 -05:00
Thomas Pelletier c862c344b3 Decoder: allow commas in tags (#693) 2021-11-30 21:59:22 -05:00