Skip to content

matchiter: capture metric NgramLookups#608

Merged
keegancsmith merged 1 commit into
mainfrom
k/ngram-stats-2
Jun 29, 2023
Merged

matchiter: capture metric NgramLookups#608
keegancsmith merged 1 commit into
mainfrom
k/ngram-stats-2

Conversation

@keegancsmith

Copy link
Copy Markdown
Member

This instruments our matchiter code to track how often is calls Get on the underlying ngram index. We have some queries on long strings which are going much slower than expected and we suspect it is related to the work done here.

This change requires a few moving pieces:

  • Adding the int to Stats
  • Instrumenting places we log/emit Stats
  • grpc support
  • capturing this work in matchiter code
  • updating tests to ensure correctness

The last two points are the meat of this commit, while the rest was mechanical work. I reworked the TestAndSearch since into TestSearchStats since it was the only test which had useful assertions on Stats.

I was surprised to see how high the ngram lookup values were for such simple queries. This makes me more confident in improving our performance here.

Test Plan: go test

Depends on #607
Part of https://github.com/sourcegraph/sourcegraph/issues/54950

@keegancsmith keegancsmith requested review from a team and stefanhengl June 28, 2023 19:02
Comment thread index_test.go

func TestAndSearch(t *testing.T) {
b := testIndexBuilder(t, nil,
func TestSearchStats(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a simple way to test noMatchTree's new stats? Or maybe that is handled in another test case?

@keegancsmith keegancsmith Jun 29, 2023

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.

It is tested in the test case I added "one-trigram-pruned"

@gl-srgr gl-srgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one comment but otherwise lgtm

Base automatically changed from k/ngram-stats to main June 29, 2023 10:17
This instruments our matchiter code to track how often is calls Get on
the underlying ngram index. We have some queries on long strings which
are going much slower than expected and we suspect it is related to the
work done here.

This change requires a few moving pieces:
- Adding the int to Stats
- Instrumenting places we log/emit Stats
- grpc support
- capturing this work in matchiter code
- updating tests to ensure correctness

The last two points are the meat of this commit, while the rest was
mechanical work. I reworked the TestAndSearch since into TestSearchStats
since it was the only test which had useful assertions on Stats.

I was surprised to see how high the ngram lookup values were for such
simple queries. This makes me more confident in improving our
performance here.

Test Plan: go test
@keegancsmith keegancsmith merged commit 7643f3b into main Jun 29, 2023
@keegancsmith keegancsmith deleted the k/ngram-stats-2 branch June 29, 2023 10:18
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