Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type expression cache (66% performance improvement) #10

Merged
merged 1 commit into from
Feb 18, 2021

Conversation

slimsag
Copy link
Member

@slimsag slimsag commented Feb 18, 2021

With complex data types, this can provide a 66% performance improvement.

Before:

$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       2	 564812395 ns/op
PASS
ok  	github.com/hexops/valast	9.372s

After:

$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       6	 189646854 ns/op
PASS
ok  	github.com/hexops/valast	6.379s

In practice this can result in tests running much faster, before:

--- PASS: TestUnionMerge (6.38s)
    --- PASS: TestUnionMerge/#00 (1.42s)
    --- PASS: TestUnionMerge/#01 (1.17s)
    --- PASS: TestUnionMerge/#02 (2.32s)
    --- PASS: TestUnionMerge/#03 (0.00s)
    --- PASS: TestUnionMerge/#04 (0.00s)
    --- PASS: TestUnionMerge/#05 (1.46s)

After:

--- PASS: TestUnionMerge (2.96s)
    --- PASS: TestUnionMerge/#00 (1.05s)
    --- PASS: TestUnionMerge/#01 (0.77s)
    --- PASS: TestUnionMerge/#02 (0.77s)
    --- PASS: TestUnionMerge/#03 (0.00s)
    --- PASS: TestUnionMerge/#04 (0.00s)
    --- PASS: TestUnionMerge/#05 (0.37s)

Also appears to fix hexops/autogold#16

Signed-off-by: Stephen Gutekanst stephen@hexops.com

With complex data types, this can provide a 66% performance improvement.

Before:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       2	 564812395 ns/op
PASS
ok  	github.com/hexops/valast	9.372s
```

After:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       6	 189646854 ns/op
PASS
ok  	github.com/hexops/valast	6.379s
```

In practice this can result in tests running much faster, before:

```
--- PASS: TestUnionMerge (6.38s)
    --- PASS: TestUnionMerge/#00 (1.42s)
    --- PASS: TestUnionMerge/#1 (1.17s)
    --- PASS: TestUnionMerge/#2 (2.32s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (1.46s)
```

After:

```
--- PASS: TestUnionMerge (2.96s)
    --- PASS: TestUnionMerge/#00 (1.05s)
    --- PASS: TestUnionMerge/#1 (0.77s)
    --- PASS: TestUnionMerge/#2 (0.77s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (0.37s)
```

Also appears to fix hexops/autogold#16

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@slimsag slimsag merged commit 6fff268 into main Feb 18, 2021
@slimsag slimsag deleted the sg/cache-type-expressions branch February 18, 2021 08:43
slimsag added a commit to hexops/autogold that referenced this pull request Feb 18, 2021
…ne formatting)

* 66% performance improvement: hexops/valast#10
* Fixes performance issues on very large structures: #16
* Improves formatting of very long lines: mvdan/gofumpt#70 (comment)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@slimsag slimsag mentioned this pull request Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop
1 participant