Repository navigation
fix(workbench): use max timeline ID instead of timeline count for filter bitset - #1175
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the timeline filtering logic in both the Go backend and Angular frontend to use the maximum timeline ID instead of the total timeline count. This change correctly handles scenarios with gapped timeline IDs (e.g., due to discarded IDs during concurrent path creation) and ensures they are preserved in EXCLUDE mode. The review feedback points out a performance inefficiency in the newly added Go test, where calling MaxTimelineID() inside a loop condition results in O(N^2) complexity; caching this value in a local variable before the loop is recommended.
| } | ||
|
|
||
| var sequentialIDs []uint32 | ||
| for id := uint32(1); id <= wb.searchIndex.MaxTimelineID(); id++ { |
There was a problem hiding this comment.
Evaluating wb.searchIndex.MaxTimelineID() in the loop condition causes it to be executed on every iteration. Since MaxTimelineID() iterates over all timelines, this results in an
| for id := uint32(1); id <= wb.searchIndex.MaxTimelineID(); id++ { | |
| maxID := wb.searchIndex.MaxTimelineID() | |
| for id := uint32(1); id <= maxID; id++ { |
| this._context.set({ | ||
| timelineIds: IdBitset.fromSequential(this.store.timelines.length), | ||
| timelineIds: IdBitset.fromSequential(this.store.maxTimelineId), | ||
| logIds: IdBitset.fromSequential(this.store.logStore.count), |
There was a problem hiding this comment.
The ID generation algorithm is same for timelines and logs. Thus the same bug should be occurred in logs as well. Wouldn't it be possible to apply the same fix for logs as well?
ec91c7b to
f66f28b
Compare
f66f28b to
54f219c
Compare
ed75074
Summary
Fixes an issue where timelines with IDs greater than the total timeline count were erroneously dropped during filter execution when timeline IDs contain gaps.
Problem
Previously, both the backend filter pipeline (
Pipeline.Execute) and the frontend filter pipeline (BackendFilter.processandTimelineView) initialized theirBitSetinstances using the number of timelines (len(index.Timelines)on the backend andtimelines.lengthon the frontend).Because timeline IDs are used as indices into the
BitSetand are not guaranteed to be contiguous from1toN(e.g., when intermediate IDs are skipped), any timeline withID > countfell outside the initialized bitset range and was inadvertently filtered out (for example, during initial bitset construction orEXCLUDEmode operations).