fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Indexing: properly block on shard building (#689)

When indexing, we build shards in parallel based on the `parallelism` flag.
Each shard handles ~100MB of document contents, which should limit the memory
usage to roughly `100MB * parallelism`.

Looking at the size of the buffered document contents in memory profiles, we
see much higher usage than this. The issue seems to be that we continue to
buffer up documents even if all threads are busy building shards. This can be a
real problem if shards take a super long time to build (say because ctags is
slow) -- we could end up buffering a ton of content into memory at once.

This change fixes the throttling logic so we block indexing when all threads
are busy building shards.

+1 -1
+1 -1
build/builder.go
··· 854 854 855 855 if b.opts.Parallelism > 1 && b.opts.MemProfile == "" { 856 856 b.building.Add(1) 857 + b.throttle <- 1 857 858 go func() { 858 - b.throttle <- 1 859 859 done, err := b.buildShard(todo, shard) 860 860 <-b.throttle 861 861