Skip to content

shards: only trigger rescan on .zoekt files changing#801

Merged
keegancsmith merged 1 commit into
mainfrom
k/use-events
Aug 2, 2024
Merged

shards: only trigger rescan on .zoekt files changing#801
keegancsmith merged 1 commit into
mainfrom
k/use-events

Conversation

@keegancsmith

Copy link
Copy Markdown
Member

Any write to the index dir triggered a scan. This means on busy instances we are constantly rescanning, leading to an over-representation in CPU profiles around watch. The events are normally writes to our temporary files. By only considering events for .zoekt files (which is what scan reads) we can avoid the constant scan calls.

Just in case we also introduce a re-scan every minute in case we miss an event. There is error handling around this, but I thought it is just more reliable to call scan every once in a while.

Note: this doesn't represent significant CPU use, but it does muddy the CPU profiler output. So this makes it easier to understand trends in our continuous cpu profiling.

Test Plan: CI

@keegancsmith keegancsmith requested a review from a team August 2, 2024 09:32
@cla-bot cla-bot Bot added the cla-signed label Aug 2, 2024
Any write to the index dir triggered a scan. This means on busy
instances we are constantly rescanning, leading to an
over-representation in CPU profiles around watch. The events are
normally writes to our temporary files. By only considering events for
.zoekt files (which is what scan reads) we can avoid the constant scan
calls.

Just in case we also introduce a re-scan every minute in case we miss an
event. There is error handling around this, but I thought it is just
more reliable to call scan every once in a while.

Note: this doesn't represent significant CPU use, but it does muddy the
CPU profiler output. So this makes it easier to understand trends in our
continuous cpu profiling.

Test Plan: CI
Comment thread shards/watcher.go
}
}

ticker := time.NewTicker(time.Minute)

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.

That seems fairly frequent for a fail-safe? Isn't this roughly in the order of magnitude we scanned before this PR? I might be totally off though ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We are always scanning right now on dotcom. IE as soon as one scan is done another starts. The scanning doesn't take long (~50ms?) but effectively we do this for { scan() }. So once a minute seems good?

@keegancsmith keegancsmith merged commit acacc5e into main Aug 2, 2024
@keegancsmith keegancsmith deleted the k/use-events branch August 2, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants