Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing: limit shard parallelism when index concurrency is set #699

Merged
merged 2 commits into from
Nov 17, 2023

Conversation

jtibshirani
Copy link
Member

By default, zoekt-sourcegraph-indexserver builds one repo at a time. For each
repo, shards are built in parallel using a number of threads equal to available
CPUs. There are two ways to adjust the indexing concurrency:

  1. Passing cpu_fraction, which limits the available CPUs for parallel shard
    building
  2. Passing index_concurrency (or setting the SRC_INDEX_CONCURRENCY
    environment variable), to index more than one repo at once

If you set index_concurrency to some number greater than 1, then indexing
will use more threads than available CPUs. This seems undesirable, especially
if you set cpu_fraction, since you'd expect that to put an upper bound on CPU
usage.

This changes the shard-level parallelism to available CPUs / index_concurrency
(rounded down), to bound the CPU usage as expected.

Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

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

FYI in practice indexConcurrency value is never configured. I think I know of one customer who uses this setting and we don't document it anywhere.

@@ -641,11 +641,12 @@ func sglogBranches(key string, branches []zoekt.RepositoryBranch) sglog.Field {
}

func (s *Server) indexArgs(opts IndexOptions) *indexArgs {
parallelism := s.CPUCount / s.IndexConcurrency
Copy link
Member

Choose a reason for hiding this comment

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

minor: do you think we should round up rather than down? I would rather slightly oversubscribe and let the OS take care of it rather than under utilize. I suppose the issue is RAM? But even then my gut says obsersubscribe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed I think that's a better trade-off, will update this.

I was thinking about it like... if you set CPU fraction then you want that to be an upper-bound on CPU use... but in practice it's more like a hint?

@jtibshirani
Copy link
Member Author

FYI in practice indexConcurrency value is never configured

Got it! I just saw it was configured on dot com and wanted to avoid spawning too many ctags processes there (when we move towards parallel symbol building for shards).

@jtibshirani jtibshirani merged commit ef907c2 into main Nov 17, 2023
8 checks passed
@jtibshirani jtibshirani deleted the jtibs/parallelism branch November 17, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants