You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(embedded): stop paying per value in the conversion layer
value_to_py runs for every column of every row, so anything it does per
call is multiplied by the size of the result set. Three costs there were
avoidable:
The tag lookup went through the import machinery and an attribute fetch
on every converted value, to reach a class that never changes. It is now
resolved once per process. Measured at 372 ns per value: 0.11 ms on a
300-row result, 37 ms on 100k. A failed lookup is cached too, since a
package that is not importable at the first conversion will not become
importable later in the same process.
A path hop cloned its type string although the arm owns the path and
drops it on the way out. Consuming it moves the string instead of
duplicating it once per hop.
Vectors, a path's node list and each multi-vector row grew by append with
their length already known. Sizing the list once measures 79.52 -> 78.94 ms
best and 81.14 -> 79.91 ms median on 200 rows of 768 floats, which is about
a percent and near the noise on that sample, but it points the same way in
both statistics and replaces a loop with one line. An embedding is the one
value here that routinely runs to thousands of elements.
Value::Array keeps its append loop on purpose: its items need a fallible
recursive conversion, so sizing it once would mean collecting into an
intermediate Vec and trading a growth reallocation for a whole allocation.
0 commit comments