[query] Intern values in query parser #153
Labels
No labels
A-build
A-cli
A-core
A-design
A-edn
A-ffi
A-query
A-sdk
A-sdk-android
A-sdk-ios
A-sync
A-transact
A-views
A-vocab
P-Android
P-desktop
P-iOS
bug
correctness
dependencies
dev-ergonomics
discussion
documentation
duplicate
enhancement
enquiry
good first bug
good first issue
help wanted
hygiene
in progress
invalid
question
ready
size
speed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/mentat#153
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It's currently difficult for us to add any kind of interning to the EDN parser: see https://github.com/kevinmehall/rust-peg/issues/84.
However, in #395 I'm about to make
Variable
andTypedValue
wrappers around anRc
. We thus have an opportunity to intern query parts within the query parser itself, even if the EDN value stream itself contains duplicate stringsThis has some immediate value: not only do we get cloneable
ConjoiningClauses
(and other consumers ofVariable
andTypedValue
) — the point of #395 — but also as we drop the repeated[edn::Value]
parser inputs we can prune some memory.To do this involves maintaining state for the duration of our
combine
parse: probably a little struct around a fewInternSet<PlainSymbol>
andInternSet<String>
instances.This would be threaded into the top parser (
Find::find
), and then down into each parser it creates. I think the simplest way to do that — avoiding lifetime and mutability issues — is to wrap our interner in anRc
and pass it by cloning. (It's theoretically possible to use aThreadLocal
for this, but global state is a bit of a downer.)We'd discard the interner when we're done with the parse. A future optimization is to keep it around….