search input: no debouncing done on suggestions
Created by: keegancsmith
I was monitoring indexed-search logs and noticed as I typed a query we would send every substring as a search query. I would of expected some debouncing here. See the recording of logs and search at the same time in production.
Note: we have 3 replicas, so each query will be logged 3 times.
Not only do we do a query for every prefix of the "hello world" I typed above quickly, but for each prefix we do two separate queries:
- check for content or path matches
- check for symbol matches
When there is 1 token, we additionally check for path matches (which we already do above). So our suggestions code is heavily overloading our zoekt instances:
Proposal:
- Only do suggestions once our token length is 3 or more.
- debounce, ie only query for suggestions after 300ms of the user not typing.
- audit the suggestion code so it doesn't do unneccessary/broken work.
This might be a contributing factor to https://github.com/sourcegraph/sourcegraph/issues/9001
Feel free to break this out into smaller issues.
Here is the full list of zoekt queries sent for me typing "hello world" without hitting enter (ie only suggestions)
grep -o 'q=.*Options' kubernetes.txt | sort | uniq
q=(and (reposet github.com/kubernetes/kubernetes) (and regex:"(?-s:.)" file_substr:"h")) Options
q=(and (reposet github.com/kubernetes/kubernetes) (and regex:"(?-s:.)" file_substr:"he")) Options
q=(and (reposet github.com/kubernetes/kubernetes) (and regex:"(?-s:.)" file_substr:"hel")) Options
q=(and (reposet github.com/kubernetes/kubernetes) (and regex:"(?-s:.)" file_substr:"hell")) Options
q=(and (reposet github.com/kubernetes/kubernetes) (and regex:"(?-s:.)" file_substr:"hello")) Options
q=(and (reposet github.com/kubernetes/kubernetes) regex:"(hello)(?-s:.)*?(w)") Options
q=(and (reposet github.com/kubernetes/kubernetes) regex:"(hello)(?-s:.)*?(wo)") Options
q=(and (reposet github.com/kubernetes/kubernetes) regex:"(hello)(?-s:.)*?(wor)") Options
q=(and (reposet github.com/kubernetes/kubernetes) regex:"(hello)(?-s:.)*?(worl)") Options
q=(and (reposet github.com/kubernetes/kubernetes) regex:"(hello)(?-s:.)*?(world)") Options
q=(and (reposet github.com/kubernetes/kubernetes) substr:"h") Options
q=(and (reposet github.com/kubernetes/kubernetes) substr:"he") Options
q=(and (reposet github.com/kubernetes/kubernetes) substr:"hel") Options
q=(and (reposet github.com/kubernetes/kubernetes) substr:"hell") Options
q=(and (reposet github.com/kubernetes/kubernetes) substr:"hello") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:regex:"(hello)(?-s:.)*?(w)") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:regex:"(hello)(?-s:.)*?(wo)") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:regex:"(hello)(?-s:.)*?(wor)") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:regex:"(hello)(?-s:.)*?(worl)") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:regex:"(hello)(?-s:.)*?(world)") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:substr:"h") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:substr:"he") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:substr:"hel") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:substr:"hell") Options
q=(and (reposet github.com/kubernetes/kubernetes) sym:substr:"hello") Options