fix(autoindex): raise RLIMIT_NOFILE (Too many open files crash) + tree-sitter AST code extraction - #82
Merged
Merged
Conversation
Two user-reported problems autoindexing large source trees (django, redis), plus a real new capability. 1. `Too many open files (os error 24)` mid-run. Every index holds segment mmaps, a WAL and a merge task, so discovering a repo (django infers ~74 datasets → ~74 indices) opens thousands of descriptors. On a default macOS soft limit (256) the server exhausted them at the 2nd index. Reproduced against a real django clone under `ulimit -n 256`. Fix: raise RLIMIT_NOFILE to the hard limit at server startup (step down for the macOS kernel cap; best-effort). Django + Redis now index cleanly under a 256 soft limit (was: crash at index #2). 2. `<jemalloc>: option background_thread currently supports pthread only` on every macOS launch. `background_thread:true` is Linux-only; gate it to `target_os = "linux"` and keep the decay policy elsewhere. 3. Source code was indexed as plain text. Add an AST extractor (extract/code.rs) using tree-sitter for python, javascript, typescript, tsx, rust, go, java, c, c++, ruby, php, c#, bash — routed by extension via a new `Family::Code`. Each file carries `language`, a structured `symbols` array {name,kind,line}, a searchable `defs` list ("class User", "def save") and the full source, so `class Model` retrieves the file that defines it. 13 per-language tests + the full 140-test autoindex suite pass; verified on real django (Python) and redis (C) clones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes user reports of
xerj autoindexcrashing on large source trees (django, redis), plus a new AST capability.1.
Too many open files (os error 24)— the crashEvery index holds segment mmaps, a WAL and a merge task; discovering a repo (django infers ~74 datasets → ~74 indices) opens thousands of descriptors. On a default macOS soft limit (256) the server exhausts them — the reporter crashed at the 2nd index. Reproduced against a real
djangoclone underulimit -n 256(create index …-2 → 500 store_exception "Too many open files").Fix: raise
RLIMIT_NOFILEto the hard limit at server startup (main.rs), stepping down for the macOS kernel cap; best-effort/non-fatal. Verified: with the fix, the server underulimit -n 256bumps its limit to the hard cap and Django + Redis both index cleanly, zero EMFILE.2. jemalloc macOS warning
<jemalloc>: option background_thread currently supports pthread onlyon every macOS launch —background_thread:trueis Linux-only. Gated totarget_os = "linux".3. AST code extraction (new)
Source files were indexed as plain text. New
extract/code.rsparses each file with the matching tree-sitter grammar (python, javascript, typescript, tsx, rust, go, java, c, c++, ruby, php, c#, bash) via a newFamily::Code, emittinglanguage, a structuredsymbolsarray{name,kind,line}, a searchabledefslist, and the full source. A search likeclass Modelnow retrieves the files that define it.Grammars decouple from the core via
tree-sitter-language, so one tree-sitter 0.25 core serves all (ABI 13–15).Verification
class Modelsearch → 14 files) and redis (C functions extracted; indexes with zero EMFILE).-D warnings, 1.97.0) clean on the changed crates.Release-bumped to rc.8 separately on main after merge.