Skip to content

fix(workbench): use max timeline ID instead of timeline count for filter bitset - #1175

Merged
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
K53:push-rownwypmrumv
Oct 26, 2026
Merged

kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
K53:push-rownwypmrumv

Conversation

@K53

@K53 K53 commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

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.process and TimelineView) initialized their BitSet instances using the number of timelines (len(index.Timelines) on the backend and timelines.length on the frontend).

Because timeline IDs are used as indices into the BitSet and are not guaranteed to be contiguous from 1 to N (e.g., when intermediate IDs are skipped), any timeline with ID > count fell outside the initialized bitset range and was inadvertently filtered out (for example, during initial bitset construction or EXCLUDE mode operations).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/server/workbench/pipeline_test.go Outdated
}

var sequentialIDs []uint32
for id := uint32(1); id <= wb.searchIndex.MaxTimelineID(); id++ {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 $O(N^2)$ complexity. Store the maximum ID in a local variable before the loop to avoid redundant calculations.

Suggested change
for id := uint32(1); id <= wb.searchIndex.MaxTimelineID(); id++ {
maxID := wb.searchIndex.MaxTimelineID()
for id := uint32(1); id <= maxID; id++ {
Comment thread pkg/server/workbench/index.go Resolved
this._context.set({
timelineIds: IdBitset.fromSequential(this.store.timelines.length),
timelineIds: IdBitset.fromSequential(this.store.maxTimelineId),
logIds: IdBitset.fromSequential(this.store.logStore.count),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@K53
K53 force-pushed the push-rownwypmrumv branch from ec91c7b to f66f28b Compare October 26, 2026 06:09
@K53
K53 force-pushed the push-rownwypmrumv branch from f66f28b to 54f219c Compare October 26, 2026 06:18
@kyasbal
kyasbal enabled auto-merge October 26, 2026 07:20

@kyasbal kyasbal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kyasbal
kyasbal added this pull request to the merge queue Oct 26, 2026
Merged via the queue into GoogleCloudPlatform:main with commit ed75074 Oct 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants