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

Commit

Permalink
gomod: update zoekt to remove perf regression in go 1.22 (#61515)
Browse files Browse the repository at this point in the history
This updates zoekt to have one more commit. See details of commit for
more information.

sourcegraph/zoekt@8cf8887...c39011a

- c39011a141 all: use a faster vendored regexp/syntax/Regexp.String

Test Plan: CI
  • Loading branch information
keegancsmith authored Apr 2, 2024
1 parent 0f2c5bd commit a86aaef
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
4 changes: 2 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5294,8 +5294,8 @@ def go_dependencies():
name = "com_github_sourcegraph_zoekt",
build_file_proto_mode = "disable_global",
importpath = "github.com/sourcegraph/zoekt",
sum = "h1:QnS7KZETcE9g2CvBCF423BMhIXIwtxuvck3N7SKBJC0=",
version = "v0.0.0-20240327102325-8cf8887a903a",
sum = "h1:tMqptvT8zd2xD1Yl11zDd42fBHxlT40zJoPU+Vl8REI=",
version = "v0.0.0-20240402071238-c39011a14191",
)
go_repository(
name = "com_github_spaolacci_murmur3",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ require (
github.com/scim2/filter-parser/v2 v2.2.0
github.com/sourcegraph/conc v0.3.1-0.20240108182409-4afefce20f9b
github.com/sourcegraph/mountinfo v0.0.0-20240201124957-b314c0befab1
github.com/sourcegraph/zoekt v0.0.0-20240327102325-8cf8887a903a
github.com/sourcegraph/zoekt v0.0.0-20240402071238-c39011a14191
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1690,8 +1690,8 @@ github.com/sourcegraph/scip v0.3.3 h1:3EOkChYOntwHl0pPSAju7rj0oRuujh8owC4vjGDEr0
github.com/sourcegraph/scip v0.3.3/go.mod h1:Q67VaoTpftINIy/CLrkYQOMwlsx67h8ys+ligmdUcqM=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/sourcegraph/zoekt v0.0.0-20240327102325-8cf8887a903a h1:QnS7KZETcE9g2CvBCF423BMhIXIwtxuvck3N7SKBJC0=
github.com/sourcegraph/zoekt v0.0.0-20240327102325-8cf8887a903a/go.mod h1:+j+huwz4ZnffJmDHeLJyI9AY4a8DKQnfNV0J//upnyo=
github.com/sourcegraph/zoekt v0.0.0-20240402071238-c39011a14191 h1:tMqptvT8zd2xD1Yl11zDd42fBHxlT40zJoPU+Vl8REI=
github.com/sourcegraph/zoekt v0.0.0-20240402071238-c39011a14191/go.mod h1:+j+huwz4ZnffJmDHeLJyI9AY4a8DKQnfNV0J//upnyo=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
8 changes: 4 additions & 4 deletions internal/search/job/jobutil/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func TestNewPlanJob(t *testing.T) {
(repoScope . [(and branch="HEAD" rawConfig:RcOnlyPublic|RcNoForks|RcNoArchived)])
(includePrivate . true)
(globalZoektQueryRegexps . [(?i)(?-s:ok.*?ok)])
(query . regex:"(?-s:ok.*?ok)")
(query . regex:"ok(?-s:.)*?ok")
(type . text))
(REPOSEARCH
(repoOpts.repoFilters . [(?:ok).*?(?:ok)])
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestNewPlanJob(t *testing.T) {
(repoScope . [(and branch="HEAD" rawConfig:RcOnlyPublic|RcNoForks|RcNoArchived)])
(includePrivate . true)
(globalZoektQueryRegexps . [(?i)(?-s:foo.*?@bar)])
(query . regex:"(?-s:foo.*?@bar)")
(query . regex:"foo(?-s:.)*?@bar")
(type . text))
REPOSCOMPUTEEXCLUDED
NOOP)))))
Expand Down Expand Up @@ -880,7 +880,7 @@ func TestNewPlanJob(t *testing.T) {
(repoScope . [(and branch="HEAD" rawConfig:RcOnlyPublic|RcNoForks|RcNoArchived)])
(includePrivate . true)
(globalZoektQueryRegexps . [(?i)(?-s:a.*b)])
(query . regex:"(?-s:a.*b)")
(query . regex:"a(?-s:.)*b")
(type . text))
REPOSCOMPUTEEXCLUDED
NOOP))))))
Expand Down Expand Up @@ -915,7 +915,7 @@ func TestNewPlanJob(t *testing.T) {
(fileMatchLimit . 10000)
(select . )
(zoektQueryRegexps . [(?i)(?-s:a.*b)])
(query . regex:"(?-s:a.*b)")
(query . regex:"a(?-s:.)*b")
(type . text))))
(REPOPAGER
(containsRefGlobs . false)
Expand Down
40 changes: 18 additions & 22 deletions internal/search/zoekt/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package zoekt
import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hexops/autogold/v2"

"github.com/sourcegraph/sourcegraph/internal/search"
Expand All @@ -17,79 +16,79 @@ func TestQueryToZoektQuery(t *testing.T) {
Type search.IndexedRequestType
Query string
Features search.Features
WantZoektOutput string
WantZoektOutput autogold.Value
}{
{
Name: "substr",
Type: search.TextRequest,
Query: `foo patterntype:regexp`,
WantZoektOutput: `substr:"foo"`,
WantZoektOutput: autogold.Expect(`substr:"foo"`),
},
{
Name: "symbol substr",
Type: search.SymbolRequest,
Query: `foo patterntype:regexp type:symbol`,
WantZoektOutput: `sym:substr:"foo"`,
WantZoektOutput: autogold.Expect(`sym:substr:"foo"`),
},
{
Name: "regex",
Type: search.TextRequest,
Query: `(foo).*?(bar) patterntype:regexp`,
WantZoektOutput: `regex:"(?-s:foo.*?bar)"`,
WantZoektOutput: autogold.Expect(`regex:"foo(?-s:.)*?bar"`),
},
{
Name: "path",
Type: search.TextRequest,
Query: `foo file:\.go$ file:\.yaml$ -file:\bvendor\b patterntype:regexp`,
WantZoektOutput: `(and substr:"foo" file_regex:"(?m:\\.go$)" file_regex:"(?m:\\.yaml$)" (not file_regex:"\\bvendor\\b"))`,
WantZoektOutput: autogold.Expect(`(and substr:"foo" file_regex:"\\.go(?m:$)" file_regex:"\\.yaml(?m:$)" (not file_regex:"\\bvendor\\b"))`),
},
{
Name: "case",
Type: search.TextRequest,
Query: `foo case:yes patterntype:regexp file:\.go$ file:yaml`,
WantZoektOutput: `(and case_substr:"foo" case_file_regex:"(?m:\\.go$)" case_file_substr:"yaml")`,
WantZoektOutput: autogold.Expect(`(and case_substr:"foo" case_file_regex:"\\.go(?m:$)" case_file_substr:"yaml")`),
},
{
Name: "casepath",
Type: search.TextRequest,
Query: `foo case:yes file:\.go$ file:\.yaml$ -file:\bvendor\b patterntype:regexp`,
WantZoektOutput: `(and case_substr:"foo" case_file_regex:"(?m:\\.go$)" case_file_regex:"(?m:\\.yaml$)" (not case_file_regex:"\\bvendor\\b"))`,
WantZoektOutput: autogold.Expect(`(and case_substr:"foo" case_file_regex:"\\.go(?m:$)" case_file_regex:"\\.yaml(?m:$)" (not case_file_regex:"\\bvendor\\b"))`),
},
{
Name: "path matches only",
Type: search.TextRequest,
Query: `test type:path`,
WantZoektOutput: `file_substr:"test"`,
WantZoektOutput: autogold.Expect(`file_substr:"test"`),
},
{
Name: "content matches only",
Type: search.TextRequest,
Query: `test type:file patterntype:literal`,
WantZoektOutput: `content_substr:"test"`,
WantZoektOutput: autogold.Expect(`content_substr:"test"`),
},
{
Name: "content and path matches",
Type: search.TextRequest,
Query: `test`,
WantZoektOutput: `substr:"test"`,
WantZoektOutput: autogold.Expect(`substr:"test"`),
},
{
Name: "Just file",
Type: search.TextRequest,
Query: `file:\.go$`,
WantZoektOutput: `file_regex:"(?m:\\.go$)"`,
WantZoektOutput: autogold.Expect(`file_regex:"\\.go(?m:$)"`),
},
{
Name: "Languages get passed as file filter",
Type: search.TextRequest,
Query: `file:\.go$ lang:go`,
WantZoektOutput: `(and file_regex:"(?m:\\.go$)" file_regex:"(?im:\\.GO$)")`,
WantZoektOutput: autogold.Expect(`(and file_regex:"\\.go(?m:$)" file_regex:"(?i:\\.GO)(?m:$)")`),
},
{
Name: "Languages still use case_insensitive in case sensitivity mode",
Type: search.TextRequest,
Query: `file:\.go$ lang:go case:true`,
WantZoektOutput: `(and case_file_regex:"(?m:\\.go$)" case_file_regex:"(?im:\\.GO$)")`,
WantZoektOutput: autogold.Expect(`(and case_file_regex:"\\.go(?m:$)" case_file_regex:"(?i:\\.GO)(?m:$)")`),
},
{
Name: "Language get passed as lang: query",
Expand All @@ -98,7 +97,7 @@ func TestQueryToZoektQuery(t *testing.T) {
Features: search.Features{
ContentBasedLangFilters: true,
},
WantZoektOutput: `lang:Go`,
WantZoektOutput: autogold.Expect(`lang:Go`),
},
{
Name: "Multiple languages get passed as lang queries",
Expand All @@ -107,7 +106,7 @@ func TestQueryToZoektQuery(t *testing.T) {
Features: search.Features{
ContentBasedLangFilters: true,
},
WantZoektOutput: `(and lang:Go lang:TypeScript)`,
WantZoektOutput: autogold.Expect(`(and lang:Go lang:TypeScript)`),
},
{
Name: "Excluded languages get passed as lang: query",
Expand All @@ -116,7 +115,7 @@ func TestQueryToZoektQuery(t *testing.T) {
Features: search.Features{
ContentBasedLangFilters: true,
},
WantZoektOutput: `(and lang:Go (not lang:TypeScript) (not lang:Markdown))`,
WantZoektOutput: autogold.Expect(`(and lang:Go (not lang:TypeScript) (not lang:Markdown))`),
},
{
Name: "Mixed file and lang filters",
Expand All @@ -125,7 +124,7 @@ func TestQueryToZoektQuery(t *testing.T) {
Features: search.Features{
ContentBasedLangFilters: true,
},
WantZoektOutput: `(and lang:Go lang:TypeScript file_regex:"(?m:\\.go$)")`,
WantZoektOutput: autogold.Expect(`(and lang:Go lang:TypeScript file_regex:"\\.go(?m:$)")`),
},
}
for _, tt := range cases {
Expand All @@ -140,10 +139,7 @@ func TestQueryToZoektQuery(t *testing.T) {
t.Fatal("QueryToZoektQuery failed:", err)
}

queryStr := got.String()
if diff := cmp.Diff(tt.WantZoektOutput, queryStr); diff != "" {
t.Errorf("mismatched queries during [%s] (-want +got):\n%s", tt.Name, diff)
}
tt.WantZoektOutput.Equal(t, got.String())
})
}
}
Expand Down

0 comments on commit a86aaef

Please sign in to comment.