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

Configure Feed

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

Simplify go-git optimization and reenable it (#940)

This PR re-enables the go-git optimization that was disabled in https://github.com/sourcegraph/zoekt/pull/870 because it caused a huge bug. This PR removes the part of the optimization that was causing the bug, setting `LargeObjectThreshold`.

An alternative would be to track down the root cause of the bug in go-git, so that we could keep setting `LargeObjectThreshold`. However, I don't feel that's worth it as:
* The memory improvement from this change was pretty small (see https://github.com/sourcegraph/zoekt/pull/854)
* Eventually we want to move away from go-git towards a "vanilla" direct git usage

+1 -7
+1 -7
internal/gitindex/index.go
··· 408 408 opts.BuildOptions.RepositoryDescription.Source = opts.RepoDir 409 409 410 410 var repo *git.Repository 411 - // TODO: this now defaults to on since we found a bug in it. Once we have 412 - // fixed openRepo default to false. 413 - legacyRepoOpen := cmp.Or(os.Getenv("ZOEKT_DISABLE_GOGIT_OPTIMIZATION"), "true") 411 + legacyRepoOpen := cmp.Or(os.Getenv("ZOEKT_DISABLE_GOGIT_OPTIMIZATION"), "false") 414 412 if b, err := strconv.ParseBool(legacyRepoOpen); b || err != nil { 415 413 repo, err = git.PlainOpen(opts.RepoDir) 416 414 if err != nil { ··· 587 585 s := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{ 588 586 // Cache the packfile handles, preventing the packfile from being opened then closed on every object access 589 587 KeepDescriptors: true, 590 - // Disable caching for most objects, by setting the threshold to 1 byte. This avoids allocating a bunch of 591 - // in-memory objects that are unlikely to be reused, since we only read each file once. Note: go-git still 592 - // proactively caches objects under 16KB (see smallObjectThreshold in packfile logic). 593 - LargeObjectThreshold: 1, 594 588 }) 595 589 596 590 // Because we're keeping descriptors open, we need to close the storage object when we're done.