Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't truncate file before detecting language #740

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

jtibshirani
Copy link
Member

Currently, we truncate a file's contents to 2048 bytes before passing it to
go-enry. I ran into a few cases where this is causing us to misclassify
files.

This PR removes the truncation. It should still be fine in terms of
performance, since go-enry is quite fast in general: ~1ms in my local
testing, even for large files. And we only run language detection if we plan to
index the file, which means we skip binary files and large files.

@jtibshirani
Copy link
Member Author

I tried indexing sgtest/megarepo, and did not detect a difference in latency:

go run ./cmd/zoekt-index -parallelism 1 ../megarepo

Before: 7 min, 4 sec
After: 7 min, 14 sec

Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

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

nice idea comparing latency on megarepo.

@jtibshirani jtibshirani merged commit 1c158f9 into main Feb 12, 2024
8 checks passed
@jtibshirani jtibshirani deleted the jtibs/lang-detection branch February 12, 2024 02:11
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