mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-24 00:11:31 +00:00
perf: enable vitest fs module cache by default
This commit is contained in:
@@ -82,7 +82,8 @@ Think of the suites as “increasing realism” (and increasing flakiness/cost):
|
||||
- Fast-local iteration note:
|
||||
- `pnpm test:changed` runs the wrapper with `--changed origin/main`.
|
||||
- The base Vitest config marks the wrapper manifests/config files as `forceRerunTriggers` so changed-mode reruns stay correct when scheduler inputs change.
|
||||
- Use `OPENCLAW_VITEST_FS_MODULE_CACHE=1` for repeated local reruns on a stable branch when transform cost dominates.
|
||||
- Vitest's filesystem module cache is now enabled by default for Node-side test reruns.
|
||||
- Opt out with `OPENCLAW_VITEST_FS_MODULE_CACHE=0` or `OPENCLAW_VITEST_FS_MODULE_CACHE=false` if you suspect stale transform cache behavior.
|
||||
- Perf-debug note:
|
||||
- `pnpm test:perf:imports` enables Vitest import-duration reporting plus import-breakdown output.
|
||||
- `pnpm test:perf:imports:changed` scopes the same profiling view to files changed since `origin/main`.
|
||||
|
||||
@@ -39,7 +39,7 @@ For local PR land/gate checks, run:
|
||||
If `pnpm test` flakes on a loaded host, rerun once before treating it as a regression, then isolate with `pnpm vitest run <path/to/test>`. For memory-constrained hosts, use:
|
||||
|
||||
- `OPENCLAW_TEST_PROFILE=low OPENCLAW_TEST_SERIAL_GATEWAY=1 pnpm test`
|
||||
- `OPENCLAW_VITEST_FS_MODULE_CACHE=1 pnpm test:changed`
|
||||
- `OPENCLAW_VITEST_FS_MODULE_CACHE=0 pnpm test:changed`
|
||||
|
||||
## Model latency bench (local keys)
|
||||
|
||||
|
||||
@@ -2,8 +2,12 @@ import { describe, expect, it } from "vitest";
|
||||
import { loadVitestExperimentalConfig } from "../vitest.performance-config.ts";
|
||||
|
||||
describe("loadVitestExperimentalConfig", () => {
|
||||
it("returns an empty object when no perf flags are enabled", () => {
|
||||
expect(loadVitestExperimentalConfig({})).toEqual({});
|
||||
it("enables the filesystem module cache by default", () => {
|
||||
expect(loadVitestExperimentalConfig({})).toEqual({
|
||||
experimental: {
|
||||
fsModuleCache: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("enables the filesystem module cache explicitly", () => {
|
||||
@@ -18,6 +22,14 @@ describe("loadVitestExperimentalConfig", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows disabling the filesystem module cache explicitly", () => {
|
||||
expect(
|
||||
loadVitestExperimentalConfig({
|
||||
OPENCLAW_VITEST_FS_MODULE_CACHE: "0",
|
||||
}),
|
||||
).toEqual({});
|
||||
});
|
||||
|
||||
it("enables import timing output and import breakdown reporting", () => {
|
||||
expect(
|
||||
loadVitestExperimentalConfig({
|
||||
@@ -26,6 +38,7 @@ describe("loadVitestExperimentalConfig", () => {
|
||||
}),
|
||||
).toEqual({
|
||||
experimental: {
|
||||
fsModuleCache: true,
|
||||
importDurations: { print: true },
|
||||
printImportBreakdown: true,
|
||||
},
|
||||
|
||||
@@ -5,6 +5,11 @@ const isEnabled = (value: string | undefined): boolean => {
|
||||
return normalized === "1" || normalized === "true";
|
||||
};
|
||||
|
||||
const isDisabled = (value: string | undefined): boolean => {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
return normalized === "0" || normalized === "false";
|
||||
};
|
||||
|
||||
export function loadVitestExperimentalConfig(env: EnvMap = process.env): {
|
||||
experimental?: {
|
||||
fsModuleCache?: true;
|
||||
@@ -18,7 +23,7 @@ export function loadVitestExperimentalConfig(env: EnvMap = process.env): {
|
||||
printImportBreakdown?: true;
|
||||
} = {};
|
||||
|
||||
if (isEnabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
|
||||
if (!isDisabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
|
||||
experimental.fsModuleCache = true;
|
||||
}
|
||||
if (isEnabled(env.OPENCLAW_VITEST_IMPORT_DURATIONS)) {
|
||||
|
||||
Reference in New Issue
Block a user