Repository navigation
fix: improve performance - #211
Conversation
Tchips46
left a comment
There was a problem hiding this comment.
Review: performance (209ef4a)
Line numbers are at this PR's head. The compression part looks sound: Vary is set, the cache key includes size and mtime, and no new path handling was added. The findings are in the code-service changes, which the PR body doesn't mention.
Should fix
1. The incremental Problems check loses changes recorded while it waits (packages/code/src/service/code-service.ts:410-414)
- It copies
changed, awaits_declaresGlobally(changed)(file reads), and only then sets_fullCheck = falseand clears_changedSinceCheck. - Anything recorded during that await is wiped, including a
_fullCheck = truefrom a file create or delete. Example: "Add component" createscomponents/armor.tsduring a check, andmain.tskeeps "Cannot find module './components/armor'" until some later full check. - Fix: read and reset both fields before the first await:
const wasFull = this._fullCheck; this._fullCheck = false; this._changedSinceCheck.clear(); const full = wasFull || await this._declaresGlobally(changed);
2. forgetMissingTypes never reloads a package that another app already found (packages/code/src/engine/code-engine.ts:229-232, _loadTypes at 390-399)
- It deletes
_typeRootsonly when!roots.found.length, butaskedis per folder andfoundis shared across apps. - Example: client and server each have their own
node_modules, and the client has@nanoforge-dev/ecswhile the server has no dependencies yet. Afterpnpm iin the server, nothing is cleared, and the server's 2307 errors stay. - Fix: for packages in
_missing, callroots.asked.clear().
3. TypeLibraries keeps loading the old project after dispose (plugins/code-editor/src/typing/type-libraries.ts:86-100, 116-121)
- The new 8-wide queue goes through every code file, and
_load→_add→addExtraLibkeeps running afterdispose(), which runs on a project switch. - Example: switch projects during the first load of a large project. The rest of the old project is added as extra libs that nothing disposes, under
file:///apps/client/src/...paths that clash with the new project's files. - Fix: a
_disposedflag, checked in the queue loop and after the await in_load.
4. Meta cache writes can fail unhandled, and are never retried (packages/code/src/catalog/meta-cache.ts:56, 63, 82-98)
_ensureIgnored'sreadTexthas no catch, and_doWriteruns fire-and-forget. Before this PR, the same code ran under_run's try/catch._written.set(line 87) runs before the write, so after a failure, every later write of the same text is skipped for the rest of the session.- Example: the project closes, or the server goes away, while a write is pending.
- Fix: in
_write,.catch((e) => { this._written.delete(path); logger.warn(...) }).
Nice to have
pickEncoding(packages/server-core/src/http/compressed-files.ts:21) treats only the literalq=0as a refusal, sobr;q=0.0gets Brotli. Fix:parseFloat(...) === 0.lib.entry(tooling/vite-plugin/src/plugin/nanoforge-editor-plugin.ts:38): echoing the user's own value back makes Vite'smergeConfigconcatenate arrays, the same bug this PR fixes forformats.entry: ['src/index.ts']ends up twice. Fix: setentryonly whenlib?.entryis undefined.- Dev watch builds (same file, line 44) are now minified with no source map, so stack traces from hot-reloaded dev plugins become
index.js:1:NNNNN. Fix:&& !user.build?.watch. - Not checked: the vite-plugin's peer range allows Vite 7. If Vite 7's config hook has no
this.meta,'rolldownVersion' in this.metathrows. Athis?.meta &&guard is cheap.
209ef4a to
b89deb0
Compare
- code: keep changes recorded while a check reads what changed - code: ask again for types an app lacked once dependencies change - code: a meta cache write survives an unreadable .gitignore - code-editor: type libraries stop loading once disposed - server-core: any zero quality refuses an encoding - vite-plugin: keep the user's lib entry, no minify in watch builds
b89deb0 to
7422db3
Compare
What does this PR do?
The PR improve the performance of the app by compresse and minify plugins.
How do you test this PR?