Repository navigation
Commit 66a901f
perf: cache dictionary arc pointer (apache#24418)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes apache#23921.
- this PR was created on top of apache#24416, so once that is merged in we can
rebase this branch
## Rationale for this change
append_val is called once per new group on the scalar (streaming) code
path. Previously it hashed a single-element slice of the dictionary
values array on every call, paying create_hashes fixed overhead 65k
times for a high-cardinality batch. Caching the full values array hash
keyed on Arc::ptr_eq collapses that to one vectorized hash pass per
batch, yielding a 2× speedup on the all-unique case with no measurable
regression elsewhere.
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->
## What changes are included in this PR?
- DictionaryGroupValuesColumn gains a cached_values: Option<ArrayRef>
field
- append_val: on a cache miss (Arc::ptr_eq fails), hashes the entire
dict.values() array into val_hashes and stores the Arc; on a hit, reuses
val_hashes[val_idx] directly — eliminating the per-call slice(val_idx,
1) allocation and create_hashes call
<!--
There is no need to duplicate the description in the issue here, but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
## Are these changes tested?
nothing logically changed.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Are there any user-facing changes?
no
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---------
Co-authored-by: Andrew Lamb <[email protected]>1 parent e2e94ae commit 66a901f
1 file changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| 166 | + | |
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
| |||
296 | 301 | | |
297 | 302 | | |
298 | 303 | | |
299 | | - | |
300 | | - | |
301 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
302 | 323 | | |
303 | 324 | | |
304 | 325 | | |
| |||
0 commit comments