Repository navigation
Dedicated rollup writer threads, a storage format reference, and rollup code cleanup. - #5
Merged
Merged
Conversation
…wn AnalyticsStorageException.
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.
Summary
With several ingestion workers, every worker wrote its own copy of each rollup row it had touched. This PR adds dedicated rollup writer threads, set by a new option,
Ingestion.RollupWriterCount.Each writer owns a share of the rollup rows. On flush, it merges what every worker buffered for its rows and writes each row once, instead of once per worker. The writers rely on the per-row lock stripes that are already on the branch.
The PR also adds a storage format reference page and removes duplicated rollup code in queries, backfill, retention and the key codecs.
Why
Before this change, each rollup row was written 5–13 times per 2-second flush window: once by every worker that had touched it.
Measured in the playground with 1M events and 20 workers:
With 4 writers, CPU time per event is about 40% lower than in the base.
Changes
Rollup writer pool
RollupWriterPool(new): dedicated writer threads, each owning rows byRollupBufferKeyhash.RetainedRollupRows, so the existing back-pressure and flush recovery still apply.IngestionWorker:AnalyticsEngine: creates the pool and owns its lifetime. Disposing the pool stops and joins its threads.Options
Ingestion.RollupWriterCounttakes values from 1 to 64, and other values are rejected at validation. The default is 1, which is safe on single-processor machines.RollupWriterCount = WorkerCountfor both sample and benchmark ingestion.Duplication cleanup (no change in behavior)
RawSessionContributions: one definition of session contributions (bounces, duration, session page views, entrance, exit). Raw-session queries and rollup-index backfill both use it.RetentionCutoffs.RollupCutoff(granularity): the rule that day rollups use the local day and the others use UTC now lives in one place.ExpiredRecords:IsRangeExpiredandDeleteFirstOfExpiredHeadsnow take aKeyHeadLengthfunction and work for any key layout.AfterPrefixmoved toKeyCodec.KeyCodec.ReadDimensionSetId: replaces inline segment parsing inRollupIndexStore, and a fullDecodeRollupper row inRollupIndexBackfill.DeleteDefinitions.RollupAccumulator.MergeInto: one merge-or-add step with a single dictionary lookup. The pool, the writers andQueryEngine.MergeGroupsall use it.RollupValueSerializer: the section reader and the entry reader are merged into oneReadLengthPrefixed. Malformed values now share one error message: "A rollup value section or entry is empty or truncated."Flush,FlushAsyncandDisposenow throwAnalyticsStorageExceptioninstead of the raw storage exception, such asIOException. Failures outside the rollup writers, such as session persistence, still throw the raw exception.Docs
RollupWriterCountis added to the configuration and tuning pages.Tests
AWriterWritesTheRowOfWorkersThatFlushedTogetherOnceManyWorkersAndWritersCountEveryEventOnceFailuresOfSeveralWritersAreAllLoggedRollupWriterCountIsValidatedRebuiltRollupsRawQueriesAndLiveIngestionAgreeOnSessionMetricschecks that rebuilt rollups, raw queries and live ingestion give the same session metrics. It guards the shared session contributions.