perf: offload SWF→Nitro conversion to a worker-thread pool
The synchronous convertSwfToNitro / extractIconFromSwf calls (pure CPU, no DB/network) now run in a small worker pool so the main Node event loop stays free during imports — the dominant import-time CPU spike is moved off the request thread. The pool degrades gracefully to a synchronous fallback if workers can't be created, and is skipped in the test environment.
This commit is contained in:
1 parent
7116f49e2b
commit
8d1b09f151
6 files changed
+240
-14
No files matched your search
@@ -24,10 +24,20 @@ vi.mock("@/lib/services/import/core/download", () => ({
|
||||
validateSwfBytes: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/services/swf-to-nitro", () => ({
|
||||
convertSwfToNitro: vi.fn(),
|
||||
extractIconFromSwf: vi.fn(),
|
||||
}));
|
||||
vi.mock("@/lib/services/swf-to-nitro", () => {
|
||||
const convertSwfToNitro = vi.fn();
|
||||
const extractIconFromSwf = vi.fn();
|
||||
return {
|
||||
convertSwfToNitro,
|
||||
extractIconFromSwf,
|
||||
convertSwfToNitroAsync: vi.fn(async (buffer: Buffer, classname: string) =>
|
||||
convertSwfToNitro(buffer, classname),
|
||||
),
|
||||
extractIconFromSwfAsync: vi.fn(async (buffer: Buffer, classname: string) =>
|
||||
extractIconFromSwf(buffer, classname),
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
import {
|
||||
autoPriceFurni,
|
||||
|
||||
Reference in new issue
Block a user