Commit fa40708
authored
perf: optimize ascii in datafusion-functions (#23462)
## Which issue does this PR close?
N/A
## Rationale for this change
Optimize existing expression.
## What changes are included in this PR?
Rewrote calculate_ascii to skip per-element null checks in the no-null
case, use value_unchecked to avoid bounds checks, and add an ASCII
leading-byte fast path that avoids char-iterator decoding for ASCII
strings.
## Are these changes tested?
Existing tests.
Benchmark (criterion):
Wins:
- ascii_string_ascii_only (null_density=0.5): 23.96% faster (base 8224ns
-> cand 6253ns)
- ascii_string_utf8 (null_density=0.5): 17.558% faster (base 10529ns ->
cand 8680ns)
- ascii_string_ascii_only (null_density=0): 35.842% faster (base 6577ns
-> cand 4219ns)
- ascii_string_utf8 (null_density=0): 23.205% faster (base 11179ns ->
cand 8585ns)
- ascii_string_view_utf8 (null_density=0): 20.23% faster (base 11948ns
-> cand 9531ns)
- ascii_string_view_ascii_only (null_density=0): 24.794% faster (base
7063ns -> cand 5312ns)
- ascii_string_view_ascii_only (null_density=0.5): 13.057% faster (base
9270ns -> cand 8060ns)
- ascii_string_view_utf8 (null_density=0.5): 9.403% faster (base 11671ns
-> cand 10573ns)
Within noise:
- ascii_scalar_utf8view: -1.162% faster (base 44ns -> cand 44ns)
- ascii_scalar_utf8: -2.266% faster (base 43ns -> cand 44ns)
## Are there any user-facing changes?
<!--
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.
-->1 parent 5b60fcb commit fa40708
1 file changed
Lines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
137 | 168 | | |
138 | 169 | | |
139 | 170 | | |
| |||
0 commit comments