Draft
Scale startup for 10k+ streams via lazy stream indexes, startup manifest bootstrap, and bounded index FDs#337
Conversation
albe
reviewed
Jul 18, 2026
| } | ||
|
|
||
| assert((typeof matcher === 'object' || typeof matcher === 'function') && matcher !== null, 'Need to specify a matcher.'); | ||
| this.markStartupStateDirty(); |
Owner
There was a problem hiding this comment.
@copilot I dislike the heavy spread of those startupState calls, for two reasons:
- they always come in two and hence need to be both placed correctly to not break the semantics. They do not directly belong to the logic currently executed, but rather are orthogonal side effects that should be executed at some specific points
- every invocation writes a potentially pretty large JSON file to disk, twice, which very likely outweighs the other step currently taken (e.g. create new partition), i.e. it will trash performance of common paths
Under what circumstance is the dirty mark strictly necessary? Can the state persistence only be invoked when new indexes/partitions are created? Can we avoid the primaryIndexLength check, hence needing to update the state on every document write?
Contributor
Author
There was a problem hiding this comment.
Addressed in 3093427: removed broad startup-state dirty/save pairs from hot paths, introduced withStartupStateMutation(...) for structural changes, and removed the primaryLength check dependency from startup-state bootstrapping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Startup was dominated by eager stream-index opening and full filesystem scans, which does not scale with large stream counts and can exhaust file descriptors. This change decouples stream discovery from index opening, adds a persisted startup manifest fast-path, and enforces LRU limits for open secondary index handles.
Lazy stream registration and open-on-first-use
EventStore.registerStream()now records stream descriptors instead of opening each stream index during startup._allremains eagerly available.Startup manifest fast-path (
startupState)StartupStatewith versioned/checksummed payloads and atomic writes.ReadableStorage.open()now attempts bootstrap from a clean manifest and falls back to full scan when state is missing/dirty/inconsistent (including primary-length mismatch).Generic file-handle pooling + index FD limits
FileHandlePool.PartitionPoolonto the shared abstraction.IndexPoolandmaxOpenIndexesto cap concurrently open secondary index files with LRU eviction.State-sync integration for correctness-sensitive flows
Targeted behavior coverage
maxOpenIndexes.