Skip to content

windows: restore core indexing and search support - #941

Open
keegancsmith wants to merge 1 commit into
mainfrom
k/windows
Open

windows: restore core indexing and search support#941
keegancsmith wants to merge 1 commit into
mainfrom
k/windows

Conversation

@keegancsmith

@keegancsmith keegancsmith commented Apr 13, 2025

Copy link
Copy Markdown
Member

Restores Windows support for zoekt-git-index and zoekt-webserver while leaving the Unix mmap implementation unchanged. Windows index reads use mmap-go behind Windows build constraints; Linux metrics remain Linux-only. Repository paths and globs now use consistent / semantics on every OS, and fixture inputs remain LF-stable.

Windows CI runs the full index suite, a focused Git-path test, and builds both supported binaries. Literal go test ./... remains unavailable on Windows because zoekt-local-sync depends on Unix file locking and zoekt-sourcegraph-indexserver depends on Unix signals and umask; those commands remain out of scope.

@keegancsmith

Copy link
Copy Markdown
Member Author

AI Prompt

In commit 70647ba and 0d03621 we reverted support for this project building and working on windows. The project has changed quite a bit since, can you re-add support? You can run env GOOS=windows GOARCH=amd64 go build -o /dev/null ./cmd/zoekt-webserver ./cmd/zoekt-git-index to test if the build works.

Note this for why we reverted support for windows initially:

We have a suspicion that when we switched to using the mmap-go library
it contributed to an issue where zoekt-webserver stops responding on
some linux versions. Our suspicion has something to do from us
hardcoding the page size to 4k to asking the kernel and how that
interacts with THP.

So on most platforms can we stick to hardcoding the page size.

@jtibshirani jtibshirani 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.

Thanks for tackling this and reverting my revert :)

Comment thread cmd/zoekt-webserver/main.go Outdated
ConstLabels: prometheus.Labels{"path": path},
}, func() float64 {
usage, _ := disk.Usage(path)
// I know there is no error handling here, and I don't like it

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.

Tiny comment: these comments are unrelated to the change and not super useful (and also use "I" in an inaccurate way :))

Comment thread index/indexfile.go Outdated
// limitations under the License.

//go:build linux || darwin
//go:build !windows

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.

Small comment, this file could be named indexfile_unix.go for consistency with the others.

Comment thread index/indexfile_windows.go Outdated
}

func (f *indexFileFromOS) Read(off, sz uint32) ([]byte, error) {
r := make([]byte, sz)

@jtibshirani jtibshirani Apr 14, 2025

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.

If we are really supporting Windows, we should use mmap here instead of direct reads. This provides the best experience, and I think it's an easier mental model for debugging/ support, to consistently use file mapping. Maybe we could re-introduce mmap-go, but just here for Windows? Or implement it directly, doesn't look too bad.

Comment thread index/tombstones_windows.go Outdated

package index

func init() {

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.

This part doesn't look right to me -- isn't this already handled in builder_windows.go?

By the way, I'm generally confused on why we are storing the system umask and manually applying it sometimes :)

@keegancsmith

Copy link
Copy Markdown
Member Author

@jtibshirani thanks for the review! I haven't even read this yet, this was totally vibe coding (but of course would be reviewed and improved by me before marking ready for review).

@jtibshirani

Copy link
Copy Markdown
Contributor

hehe understood! I was just too interested and wanted to get in a review this week :)

@adlternative

Copy link
Copy Markdown
Contributor

Thank you for fixing this issue. However, I'm currently avoiding building zoekt for Windows in Gitea by using the go build tag "!unix" as a temporary workaround. I'll only re-enable this capability once you restore Windows support. Unfortunately, I don't have a Windows environment to test zoekt either:(

@keegancsmith keegancsmith changed the title all: re-implement Windows support windows: restore core indexing and search support Sep 4, 2026
@keegancsmith
keegancsmith force-pushed the k/windows branch 3 times, most recently from d55fe4a to dec5130 Compare September 4, 2026 09:08
Restore the Windows webserver and Git indexer without changing the Unix mmap behavior that motivated the earlier revert. Keep mmap-go isolated to Windows, make repository paths platform-independent, and run full index tests plus focused Git-path coverage on Windows so real portability regressions are caught without lengthening the critical CI path.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a06b83-5fdf-72ff-9a07-614d9a2b5f97

Copy link
Copy Markdown
Member Author

Follow-up from the Windows CI investigation:

  • Replaced OS-dependent doublestar.PathMatch with doublestar.Match, normalizing indexed names to /.
  • Standardized Git refs, repository names, submodule paths, and indexed file names on /, while retaining filepath for real filesystem paths.
  • Added .gitattributes rules to keep fixture inputs LF-stable on Windows.
  • Made shard-path tests platform-aware.
  • Expanded Windows CI to run the full index suite plus focused Git-path coverage.

All CI is green. The full index suite took 49s versus 47s for the previous targeted test, so broader coverage adds negligible test time. The 2m45s total Windows job was primarily caused by a variable 1m28s Go cache/setup step.

@keegancsmith
keegancsmith requested review from a team and stefanhengl September 4, 2026 11:27
@keegancsmith
keegancsmith marked this pull request as ready for review September 4, 2026 11:27
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.

3 participants