Repository navigation
fix(ui): load the embedder once per folder index, not once per file - #7310
Conversation
Indexing a folder of 300 small text files took 15 minutes, almost all of it reloading the embedding model: about 3 s of loading for every file, cached or not, against well under 0.1 s of embedding. A folder index now loads it once and reuses it for every file, so the same folder takes seconds. Each file built its own RAGSDK, and each one unloaded and reloaded the embedder. index_folder now runs inside one_embedder_load(), which hands the embedder one file loaded to the next. A file read with the vision model, or one that fails, gives it up, so the next file reloads it as before; single uploads are unchanged. Closes #ISSUE
|
Verdict: Approve with suggestions Indexing a folder now loads the embedding model once and reuses it for every file, instead of reloading it for each one. That reload was about 3 s per file, so a 300-file folder took about 15 minutes. The change only affects folder indexing, and every way it can fail leads back to the old load-per-file behaviour, so it is safe to merge.
Real-world evidenceN/A: no evidence bundle was produced for this run. The verdict rests on static review alone. The PR's own manual timing item (index 300 small files in the rebuilt app) is still unchecked, and the new unit tests could not be run here. 🔍 Technical details🟡 Follow-up: multi-file selection still reloads the embedder per file ( 🟢 The vision check only sees pages the vision model actually read ( Notes from tracing
Strengths
|
A folder index handed the embedder on to the next file unless the vision model read some images. The vision model can load and then read nothing, evicting the embedder all the same, so a file that left images unread now gives the embedder up too and the next file loads its own.
|
A file whose images went unread now gives the embedder up too (e523fe2). The multi-file case is left for a follow-up.
The branch already contained current main, so there was nothing to merge in. |
A file that fails mid-batch takes the embedder with it so the next file reloads, two folder indexes running at once never share one, and a single upload after a batch loads its own.
On main every indexed file still reloads the embedder (amd#7288), and 300 of them ran past 45 minutes on a hosted runner. The test keeps 300 as its default; the workflow sets GAIA_SCALE_FILES=60 and says to delete it with the fix (amd#7310). The load-count assertion fails at any size, so the strict expected failure still holds.
amd#7310 merged, so a folder index loads the embedder once and the strict expected failure on the load count now passes. 300 files index in about 25 s against the fake server, well inside the 240 s budget, so the lane drops its 60-file override and runs the size rc18 failed at.
Every unit test indexes three files and stores five memories, and rc18 fell over at 300 of each: a folder index reloaded the embedder once per file, so 300 small files took 15 minutes, and a memory search over a few hundred rows ended the turn on a JSON error. This adds a scale run that does both at a real user's size on every release tag, with no model: the installer journeys' fake model server answers, and the test asserts counts of what GAIA asked it for. What it asserts: | At scale | Assertion | Today | |---|---|---| | large folder index | every file indexed, exactly one library row each | ✅ | | large folder index | the embedder is loaded at most twice, within a time budget | ✅ (fixed by amd#7310 while this was in review; it caught amd#7288, a reload per file, before that) | | search over 500 memories | the result can be sent as JSON | ✅ (fixed by amd#7308 while this was in review; the test caught it before that) | | 500 memories | the memory API reaches every one, page by page | ✅ | **Size:** 300 files, the size rc18 failed at. With amd#7310 in, they index in about 25 s against the fake server, well inside the 240 s budget; before it, 300 ran past 45 minutes on a hosted runner (that slowness was the bug). **Not built here, and why:** the 60-turn chat with the context meter compared to what the model is sent (F59) needs a real flagship turn loop behind the relay, and the memory page showing only 200 of 500 (F63) and duplicate rows from a re-add during indexing (F65) are a frontend bug and a race. Each has its own focused test in its fix PR (amd#7309, amd#7312, amd#7311); a scale version belongs with the Electron journey proposed in amd#7343. Stacked on amd#7331 (it uses that PR's `tests/fixtures/fake_lemonade.py`); the commits before "test: run GAIA at a real user's size ..." are that PR. ## Test plan - [ ] The new **Scale Run** workflow on this PR passes (4 passed) - [ ] Locally: `GAIA_SCALE_FILES=8 python -m pytest tests/integration/test_scale_run.py -q` passes - [ ] Runs on every `v*` tag (each RC and final) and on PRs that touch the test, its fixture or the workflow <details> <summary>🔍 Technical details</summary> - The folder is indexed once per run through `POST /api/documents/index-folder` with the real RAG code; the embedder's load and unload requests are read from the fake server's log. - The time budget (240 s) sits in the same expected-failure test as the load count, since the reloads are what make it slow. </details> --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
Indexing a folder of 300 small text files took 15 minutes, almost all of it
reloading the embedding model: about 3 s of loading for every file, cached
or not, against well under 0.1 s of embedding. A folder index now loads it
once and reuses it for every file, so the same folder takes seconds.
Each file built its own RAGSDK, and each one unloaded and reloaded the
embedder. index_folder now runs inside one_embedder_load(), which hands the
embedder one file loaded to the next. A file read with the vision model,
or one that fails, gives it up, so the next file reloads it as before;
single uploads are unchanged.
Closes #7288
Test plan
python -m pytest tests/unit/chat/ui/test_folder_index_one_embedder_load.pyand the folder-indexing suites (67 pass; main loads the embedder 6 times for 6 files)