Positions without renumbering.
An initial investigation of Zed's ordered text locators, the insertion-between operation, and the limits of the available tests.
Source and core operation
The implementation is in crates/text/src/locator.rs. The type is Locator; the key operation is Locator::between(lhs, rhs).
The inspected locator is backed by SmallVec<[u64; 2]>. Its between operation constructs a value ordered between two existing locators, using numeric gaps where possible.
What the tests establish
The inspected tests include a 100,000-step sequential forward append scenario and a 10,000-insertion-at-cursor scenario. They check that locator depth remains shallow for those particular patterns.
VERIFIED - the implementation and tests explicitly exercise locator depth under large sequential and repeated-at-cursor insertion patterns.
ANALYSIS - stable ordering identifiers can remove the need to renumber every later position when inserting between existing positions. The tests indicate common typing patterns are an optimization target.
Open questions
- What depth results from repeated insertions into the same narrow interval?
- How does comparison cost scale with depth?
- Are there normalization or compaction paths?
- Which invariants apply when operations from different replicas are merged?
- Which property tests cover ordering, uniqueness, and convergence?
HYPOTHESIS TO TEST - adversarial insertion patterns may produce deeper locators and more expensive comparisons. This is not established by the common-pattern tests alone.
Benchmark plan
A useful benchmark suite should vary workload shape rather than report one aggregate number:
- Append-only insertion.
- Repeated insertion at a fixed cursor.
- Alternating insertion on both sides of a narrow interval.
- Randomized insertion among existing positions.
- Merge operations generated independently by multiple replicas.
Record elapsed time and resulting locator depth. Keep the workload, input size, hardware, and revision alongside every result.