Maximize throughput by minimizing time spent in transact critical section #86
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#86
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?
Our writes are serialized, for good and obvious reasons.
However, transact operations involve some amount of non-write processing: turning a semi-structured map into an array of
:db/add
operations, turning keywords into entids, performing validation, etc.Throughput can be increased by allowing other writes to be partially preprocessed while the current write is occurring against the DB.
(This is analogous to forcing shoppers to get out their credit cards while they're standing in line, rather than waiting until they get to the register to begin hunting in pockets and bags.)
Theoretical maximum throughput would mean queuing up only raw SQL+bindings in the transact queue itself: no transact work other than "run this SQL". That's unrealistic, because transacts (particularly upserts) depend on the transacts before them.
However, realistic opportunities exist.
[input transformed schema-counter]
, we can do preprocessing that depends on the schema, redoing the work in the unlikely event that a transact earlier in the queue change the schema.We should do two kinds of measurement:
If we don't find contention in practice — the queue never fills — then there's no point doing this work unless we think it would make the code easier to understand or is reasonable future-proofing.
If we don't find much opportunity for time savings, then there's little point in doing this work now.