kkHAIKE
8be357dfa1
Add LocalTime to interface{} decode support ( #567 )
...
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes >
2021-07-21 17:50:12 +02:00
Thomas Pelletier
618f0181ac
AST Tweaks ( #551 )
...
* Use pointers instead of copying around ast.Node
Node is a 56B struct that is constantly in the hot path. Passing nodes
around by copy had a cost that started to add up. This change replaces
them by pointers. Using unsafe pointer arithmetic and converting
sibling/child indexes to relative offsets, it removes the need to carry
around a pointer to the root of the tree. This saves 8B per Node. This
space will be used to store an extra []byte slice to provide contextual
error handling on all nodes, including the ones whose data is different
than the raw input (for example: strings with escaped characters), while
staying under the size of a cache line.
* Remove conditional
* Add Raw to track range in data for parsed values
* Simplify reference tracking
2021-06-03 21:48:51 -04:00
Thomas Pelletier
250e073408
Stack-based unmarshaler ( #546 )
...
* Benchmark script
* Rewrite unmarshaler using the stack
Instead of tracking the build chain using `target`s, use the stack
instead.
Working and most benchmarks look good, but regression on structs unmarshalling.
~60% slower on ReferenceFile/struct.
* Shortcut to check if last node of iterator
* Remove unecessary pointer allocation
* Skip over unused keys without marking them as seen
* Add some tests
* Fix mktemp on macos
2021-05-31 12:14:13 -04:00
Thomas Pelletier
390927a0cd
Reuse AST storage between top-level expressions
...
```
Comparing:
old: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
run: v2-wip/3f23ab9 (2021-03-25 22:35:06 -0400 -0400)
-----------------------------------------------------------
name old time/op new time/op delta
UnmarshalSimple/v2-8 700ns ± 3% 705ns ± 2% ~ (p=0.690 n=5+5)
UnmarshalSimple/v1-8 3.85µs ± 1% 4.02µs ± 4% +4.19% (p=0.032 n=5+5)
UnmarshalSimple/bs-8 2.34µs ± 2% 2.38µs ± 3% ~ (p=0.310 n=5+5)
ReferenceFile/v2-8 32.2µs ±13% 23.9µs ± 1% -25.79% (p=0.008 n=5+5)
ReferenceFile/v1-8 270µs ± 2% 264µs ± 2% ~ (p=0.095 n=5+5)
ReferenceFile/bs-8 291µs ± 0% 294µs ± 0% +0.88% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
ReferenceFile/v2-8 37.1kB ± 0% 6.7kB ± 0% -81.91% (p=0.008 n=5+5)
ReferenceFile/v1-8 131kB ± 0% 131kB ± 0% ~ (p=0.444 n=5+5)
ReferenceFile/bs-8 80.8kB ± 0% 80.8kB ± 0% ~ (p=0.571 n=5+5)
name old allocs/op new allocs/op delta
ReferenceFile/v2-8 152 ± 0% 148 ± 0% -2.63% (p=0.008 n=5+5)
ReferenceFile/v1-8 2.65k ± 0% 2.65k ± 0% ~ (all equal)
ReferenceFile/bs-8 1.73k ± 0% 1.73k ± 0% ~ (all equal)
~/s/g/p/g/benchmark$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/pelletier/go-toml/v2/benchmark
cpu: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
BenchmarkUnmarshalSimple/v2-8 1692444 710.7 ns/op
BenchmarkUnmarshalSimple/v1-8 307609 3862 ns/op
BenchmarkUnmarshalSimple/bs-8 520429 2285 ns/op
BenchmarkReferenceFile/v2-8 50395 24006 ns/op 6704 B/op 148 allocs/op
BenchmarkReferenceFile/v1-8 4144 264655 ns/op 130567 B/op 2649 allocs/op
BenchmarkReferenceFile/bs-8 3969 293635 ns/op 80784 B/op 1729 allocs/op
PASS
ok github.com/pelletier/go-toml/v2/benchmark 8.143s
```
2021-03-25 22:37:16 -04:00
Thomas Pelletier
1d332cd112
Add documentation for the AST
2021-03-25 20:46:31 -04:00
Thomas Pelletier
9d3a912da0
Remove unused interface
...
Comparing:
old: v2-wip/17299c9 (2021-03-25 20:19:40 -0400 -0400)
run: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
-----------------------------------------------------------
name old time/op new time/op delta
UnmarshalSimple/v2-8 755ns ± 3% 700ns ± 3% -7.26% (p=0.008 n=5+5)
UnmarshalSimple/v1-8 3.87µs ± 0% 3.85µs ± 1% ~ (p=0.254 n=4+5)
UnmarshalSimple/bs-8 2.44µs ± 4% 2.34µs ± 2% ~ (p=0.056 n=5+5)
ReferenceFile/v2-8 33.5µs ± 7% 32.2µs ±13% ~ (p=0.421 n=5+5)
ReferenceFile/v1-8 269µs ± 3% 270µs ± 2% ~ (p=1.000 n=5+5)
ReferenceFile/bs-8 296µs ± 2% 291µs ± 0% ~ (p=0.095 n=5+5)
name old alloc/op new alloc/op delta
ReferenceFile/v2-8 38.9kB ± 0% 37.1kB ± 0% -4.77% (p=0.008 n=5+5)
ReferenceFile/v1-8 131kB ± 0% 131kB ± 0% ~ (all equal)
ReferenceFile/bs-8 80.8kB ± 0% 80.8kB ± 0% ~ (p=0.841 n=5+5)
name old allocs/op new allocs/op delta
ReferenceFile/v2-8 181 ± 0% 152 ± 0% -16.02% (p=0.008 n=5+5)
ReferenceFile/v1-8 2.65k ± 0% 2.65k ± 0% ~ (all equal)
ReferenceFile/bs-8 1.73k ± 0% 1.73k ± 0% ~ (all equal)
2021-03-25 20:38:45 -04:00
Thomas Pelletier
1bae751a45
Linear array storage for AST
2021-03-25 19:56:02 -04:00
Thomas Pelletier
fcc91f2618
Progress on date/times
2021-03-22 09:59:15 -04:00
Thomas Pelletier
8b34e54764
Improve DOT representation for AST
2021-03-18 22:10:31 -04:00
Thomas Pelletier
9ec4e86883
Handle struct field name variations
2021-03-18 20:42:41 -04:00
Thomas Pelletier
f9f9ccb777
Basic array table implementation
2021-03-16 10:24:19 -04:00
Thomas Pelletier
590d674153
Unmarshal ints and floats
2021-03-14 18:06:34 -04:00
Thomas Pelletier
fbf01f7683
Handle Table
2021-03-13 22:48:31 -05:00
Thomas Pelletier
21d3e85fcc
Playing with an AST
...
Idea would be to build a light AST as a first pass, then have the
unmarshaler and Document parser do what they need with it.
2021-03-13 11:38:09 -05:00