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

frontend: reuses br_table tmp slice correctly #2253

Merged
merged 1 commit into from
Jun 14, 2024
Merged

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Jun 14, 2024

Previously, the tmpForBrTable slice hadn't been
correctly reused, and this fixes it.
As a result, for br_table heavy cases, we see the huge
drop in the number of allocations:

goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   1.995 ± 0%   1.999 ± 1%       ~ (p=0.394 n=6)
Compilation/zig-10      4.169 ± 0%   4.168 ± 1%       ~ (p=0.589 n=6)
Compilation/zz-10       18.55 ± 0%   18.55 ± 0%       ~ (p=0.818 n=6)
geomean                 5.363        5.367       +0.06%

                      │   old.txt    │              new.txt               │
                      │     B/op     │     B/op      vs base              │
Compilation/wazero-10   286.8Mi ± 0%   285.4Mi ± 0%  -0.46% (p=0.002 n=6)
Compilation/zig-10      590.3Mi ± 0%   590.1Mi ± 0%  -0.03% (p=0.002 n=6)
Compilation/zz-10       549.4Mi ± 0%   537.7Mi ± 0%  -2.12% (p=0.002 n=6)
geomean                 453.0Mi        449.1Mi       -0.88%

                      │   old.txt   │              new.txt               │
                      │  allocs/op  │  allocs/op   vs base               │
Compilation/wazero-10   445.3k ± 0%   429.0k ± 0%   -3.66% (p=0.002 n=6)
Compilation/zig-10      273.0k ± 0%   269.6k ± 0%   -1.26% (p=0.002 n=6)
Compilation/zz-10       783.3k ± 0%   605.8k ± 0%  -22.66% (p=0.002 n=6)
geomean                 456.7k        412.2k        -9.73%

#2182

@@ -1557,6 +1556,7 @@ func (c *Compiler) lowerCurrentOpcode() {
} else {
c.lowerBrTable(labels, index)
}
state.tmpForBrTable = labels // reuse the temporary slice for next use.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was missing

@mathetake mathetake merged commit c96893d into main Jun 14, 2024
58 checks passed
@mathetake mathetake deleted the reusebrtablalbes branch June 14, 2024 18:25
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.

1 participant