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 zed.Value.Under parameter to avoid allocation #4740

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Conversation

nwt
Copy link
Member

@nwt nwt commented Aug 7, 2023

Value.Under allocates memory on any call that does not return the receiver. This becomes spendy in runtime/expr.DotExpr.Eval on workloads that access fields of records with named types. Add a parameter to Under that, when not nil, points to a Value to use in lieu of allocating.

goos: darwin
goarch: arm64
pkg: github.com/brimdata/zed
                        |  before.txt  |              after.txt               |
                        |    sec/op    |    sec/op     vs base                |
ValueUnder/primitive-10   0.9348n ± 0%   0.9331n ± 1%        ~ (p=0.617 n=10)
ValueUnder/named-10       27.480n ± 0%    6.385n ± 1%  -76.76% (p=0.000 n=10)
geomean                    5.068n         2.441n       -51.84%

Value.Under allocates memory on any call that does not return the
receiver.  This becomes spendy in runtime/expr.DotExpr.Eval on workloads
that access fields of records with named types.  Add a parameter to
Under that, when not nil, points to a Value to use in lieu of
allocating.

goos: darwin
goarch: arm64
pkg: github.com/brimdata/zed
                        |  before.txt  |              after.txt               |
                        |    sec/op    |    sec/op     vs base                |
ValueUnder/primitive-10   0.9348n ± 0%   0.9331n ± 1%        ~ (p=0.617 n=10)
ValueUnder/named-10       27.480n ± 0%    6.385n ± 1%  -76.76% (p=0.000 n=10)
geomean                    5.068n         2.441n       -51.84%
@nwt nwt requested a review from a team August 7, 2023 16:38
@nwt nwt merged commit 2689e24 into main Aug 10, 2023
@nwt nwt deleted the zed.Value.Under-param branch August 10, 2023 22:04
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.

2 participants