Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

zoekt-webserver regularly using 50GB memory, OOMing at 60GB #3792

Closed
emidoots opened this issue May 2, 2019 · 12 comments
Closed

zoekt-webserver regularly using 50GB memory, OOMing at 60GB #3792

emidoots opened this issue May 2, 2019 · 12 comments
Assignees
Labels
customer Important issues reported or desired by a customer.
Milestone

Comments

@emidoots
Copy link
Member

emidoots commented May 2, 2019

On an xlarge customer deployment (https://app.hubspot.com/contacts/2762526/company/407948923) I am observing zoekt-webserver regularly using ~50GB memory and sometimes OOMing when it goes over 60GB which is the limit we have in place. We've mitigated by bumping up to 80GB but it seems a little crazy to have to do this.

Is there a way we can tell Zoekt "you can use N GB memory, but after that slow down a bit so you don't OOM"? Or is there any low-hanging fruit w.r.t. zoekt-webserver that would reduce memory consumption?

cc @sourcegraph/code-search @sourcegraph/core-services

@keegancsmith
Copy link
Member

Maybe you can try and increase the shard size flag? For a large repository I believe it may result in overall smaller indexes and lower memory usage in a request. Another possibility is reducing the number of results found per shard.

I don't think there is low hanging fruit other than what I mentioned, but maybe an inspection of some memory traces would reveal some. Otherwise there are some likely higher level changes which can be made:

  • Make indexes mmaped as well.
  • Horizontally scale zoekt-webserver.
  • Smarter decisions in which shards to search and in what order.

@emidoots
Copy link
Member Author

emidoots commented May 6, 2019

@keegancsmith I briefly looked at CLI flags for zoekt-webserver and zoekt-indexserver but didn't find a shard flag size. Can you point me to it? Also, what would you recommend trying to set it to? If we alter it how would it affect the existing indexes produced by Zoekt? (would it need to re-index or something)

@keegancsmith
Copy link
Member

@keegancsmith I briefly looked at CLI flags for zoekt-webserver and zoekt-indexserver but didn't find a shard flag size. Can you point me to it?

-shard_limit https://sourcegraph.com/github.com/sourcegraph/zoekt/-/blob/cmd/flags.go#L42:26
It would be for the index server. You would probably have to update our indexserver to set the field, we justrely on the default. @ijsnow recently added functionality allowing us to pass flags from sourcegraph down to the indexserver, so that may be the best place to do it.

Also, what would you recommend trying to set it to?

Zoekt divides its parallelism up by shards (ie there is one goroutine per shard). So how long it takes to search a shard is the critical path for how quick zoekt is assuming you had infinite cores. 100mb is quite small. As an educated guess I would suspect 1G would still result in fast searches.

If we alter it how would it affect the existing indexes produced by Zoekt? (would it need to re-index or something)

I believe all indexes will be recomputed (assuming @ijsnow work on reindexing based on command line flags has gone in). If it hasn't, it will only re-index when there is a new commit to index.

@emidoots emidoots added this to the 3.7 milestone Jul 9, 2019
@emidoots
Copy link
Member Author

emidoots commented Jul 9, 2019

Note ongoing work here: google/zoekt#86

@emidoots
Copy link
Member Author

@sourcegraph/core-services I am reassigning to you for tracking purposes. I know you're already doing some work on this in google/zoekt#86

It sounds like a good first step here would be what @tsenart suggested in google/zoekt#86 (comment) with just setting GOGC=50 in our zoekt-webserver and zoekt-indexserver containers? Any reason to not do that?

@emidoots
Copy link
Member Author

setting GOGC=50 in our zoekt-webserver and zoekt-indexserver containers

would be good to land this in 3.7 if so

@tsenart
Copy link
Contributor

tsenart commented Aug 14, 2019

would be good to land this in 3.7 if so

That sounds like a good idea. Can you land those patches?

@ijt
Copy link
Contributor

ijt commented Aug 14, 2019 via email

@emidoots
Copy link
Member Author

(I am doing so)

@ijt
Copy link
Contributor

ijt commented Aug 14, 2019 via email

emidoots referenced this issue in sourcegraph/deploy-sourcegraph-docker Aug 14, 2019
emidoots referenced this issue in sourcegraph/deploy-sourcegraph-docker Aug 14, 2019
Setting GOGC=50, see sourcegraph/sourcegraph#3792
emidoots referenced this issue in sourcegraph/deploy-sourcegraph-docker Aug 14, 2019
* update zoekt-indexserver image

Setting GOGC=50, see https://github.com/sourcegraph/sourcegraph/issues/3792

* update zoekt-webserver image

Setting GOGC=50, see sourcegraph/sourcegraph#3792
@emidoots
Copy link
Member Author

@emidoots
Copy link
Member Author

emidoots commented Aug 14, 2019

We'll see how big of an impact this has and, if insufficient, will re-open this.

emidoots referenced this issue Aug 14, 2019
* cmd/server/shared: set GOGC=50 on Zoekt (see sourcegraph/sourcegraph#3792)

* dev: set GOGC=50 on Zoekt (see sourcegraph/sourcegraph#3792)

* CHANGELOG: mention Zoekt GOGC=50 memory consumption change

* fixup
@tsenart tsenart added the customer Important issues reported or desired by a customer. label Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer Important issues reported or desired by a customer.
Projects
None yet
Development

No branches or pull requests

4 participants