pub struct BinderScratch { /* private fields */ }Expand description
The vectors a binder works in, kept by the connection rather than made for every statement.
The parse arena’s counterpart, for the stage after the parse
(task-2026). Compiled::scratch_ast exists because every vector in an
Ast is empty at construction and grows on its first push, so a parse that
is thrown away a microsecond later pays the allocator for capacity it
already had last time. The binder has exactly that shape and was not getting
that treatment: binding SELECT 1 took the scope stack’s buffer and the
result-alias buffer - 96 and 320 bytes - out of the allocator on every
compile, and prepare.trivial is a workload the gate compiles on every
iteration.
What is here is the binder’s own working state. What the binder returns is
not: a BoundStatement’s vectors leave with it and belong to whoever asked
for the bind, so recycling them would mean handing back memory something
else is still reading.
Like the arena, it is cleared on the way in rather than on the way out, and
it keeps whatever capacity the largest statement so far needed - a
connection that once bound a statement with ten thousand FROM terms holds
that much sources until it closes. That is the trade crate::ast::Ast
already makes, made once more here rather than differently.
Implementations§
Source§impl BinderScratch
impl BinderScratch
Sourcepub fn new() -> BinderScratch
pub fn new() -> BinderScratch
Returns a scratch with nothing in it and nothing allocated.