Repository navigation
[Engine] perf(weights): check source file identity once, when the file is opened - #340
Merged
Merged
Conversation
After every expert write, Weights::complete reopened each source file by path and compared both the open handle's and the reopened file's identity with the one recorded at begin_write, which itself called fstat on every write. On the 35B slot path this runs on every synchronous expert load, about 39 times per decode token. Identity is now taken once when a source file is opened and cached with its handle; writes reuse it. A source file modified while the engine is running is no longer detected, so the storage test case for that is removed, and the read-batch test now checks that a repeated write opens and stats nothing.
serve_delegate_process.cpp calls posix_spawn_file_actions_addchdir_np, which Android provides only from API 34. The android-cpu preset targets API 28 and has failed to link since 5c7f5c2. Android, like iOS, does not run the external engine's preparation scripts, so it now takes the same ENOTSUP path.
linyubupa
approved these changes
Nov 23, 2026
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.
What & why
Two changes in
edge0-infer/, one commit each.perf(weights): check source file identity once, when the file is opened.
After every expert write,
Weights::completereopened each source file by path and comparedboth the open handle's and the reopened file's identity (fstat) with the one recorded at
begin_write, which itself called fstat on every write. On the 35B slot path this runs on everysynchronous expert load, about 39 times per decode token. Identity is now taken once when a
source file is opened and cached with its handle; writes reuse it. A source file modified while
the engine is running is no longer detected, so the storage test case for that is removed, and
the read-batch test now checks that a repeated write opens and stats nothing.
fix(cli): link the Android CLI at API 28.
serve_delegate_process.cppcallsposix_spawn_file_actions_addchdir_np, which Androidprovides only from API 34. The
android-cpupreset targets API 28 and has failed to link since5c7f5c2. Android, like iOS, does not run the external engine's preparation scripts, so it now
takes the same
ENOTSUPpath.Area
edge0-infer/)edge0-infer/tools/assets/)edge0-infer/examples/)docs/)edge0-strata/How was it tested?
macOS (M5, 16 GB, Metal):
cmake --build build/mac-metalandctest --test-dir build/mac-metal -L "L0|L1": 106/106 passed.edge0-infer bench --model <Edge0 35B> --user-file tests/fixtures/bench/library-report-prompt-head.txt --warmup 10 --ntok 100 --runs 1 --breakdown(627-token input), main and this branch alternated, 3 runs each:
Android (HONOR BRM-AN00, Snapdragon SM8975, CPU):
cmake --preset android-cpu && cmake --build build/android-cpu(API 28): builds and links.moe_test_weights_storageandmoe_test_weights_read_batchpass.edge0-infer forward --device cpu --threads 4on a 627 + 120 token sequence with cached expertreads:
logits.f32is byte-identical between main (with the API 28 fix) and this branch.