@impz/testing 7.10.0 → 7.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +50 -33
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -22161,7 +22161,7 @@ import { join as join49 } from "path";
22161
22161
  // packages/daemon/package.json
22162
22162
  var package_default = {
22163
22163
  name: "@impz/daemon",
22164
- version: "7.10.0",
22164
+ version: "7.11.0",
22165
22165
  private: true,
22166
22166
  description: "impd: the imp host daemon",
22167
22167
  type: "module",
@@ -45180,43 +45180,59 @@ function createMemoryWarm(deps) {
45180
45180
  const running = new Map;
45181
45181
  const lifetime = { isStopped: false };
45182
45182
  const slots = createSemaphore(WARM_CONCURRENCY);
45183
+ const budgetBlocks = Math.floor(deps.capMib / BLOCK_MIB2);
45183
45184
  const readBlocks = async (mode, target, signal) => {
45184
45185
  signal.throwIfAborted();
45185
- const argv = isBlockListMode(mode) ? [deps.handlerBin, mode, target.blockList, target.memFile] : [deps.handlerBin, mode, target.memFile];
45186
+ const argv = match23(mode).with("--warm-blocks", () => [
45187
+ deps.handlerBin,
45188
+ mode,
45189
+ target.blockList,
45190
+ target.memFile,
45191
+ String(budgetBlocks)
45192
+ ]).with("--count-blocks", () => [deps.handlerBin, mode, target.blockList, target.memFile]).with("--count-data", "--warm", () => [deps.handlerBin, mode, target.memFile]).exhaustive();
45186
45193
  const stdout = await runChecked(argv, { signal }, deps.run);
45187
45194
  return WarmReportSchema.parse(JSON.parse(stdout)).blocks;
45188
45195
  };
45189
- const countBlocks = async (target, signal) => {
45190
- if (existsSync21(target.blockList)) {
45191
- try {
45192
- return {
45193
- scope: "recorded",
45194
- blocks: await readBlocks(RECORDED_MODES.count, target, signal)
45195
- };
45196
- } catch (error) {
45197
- signal.throwIfAborted();
45198
- getImpdLogger("imps").with({ imp: target.name }).warning("the recorded blocks of the memory file cannot be counted, so the whole file is: {error}", {
45199
- error: getErrorMessage(error)
45200
- });
45201
- }
45196
+ const warmRecorded = async (target, signal, startedMs) => {
45197
+ const recorded = await readBlocks(RECORDED_MODES.count, target, signal);
45198
+ if (recorded > 0 && budgetBlocks === 0) {
45199
+ return { kind: "overCap", scope: "recorded", blocks: recorded };
45200
+ }
45201
+ const read = recorded === 0 ? 0 : await readBlocks(RECORDED_MODES.warm, target, signal);
45202
+ return {
45203
+ kind: "warmed",
45204
+ scope: "recorded",
45205
+ blocks: read,
45206
+ scopeBlocks: recorded,
45207
+ warmMs: Math.round(performance.now() - startedMs)
45208
+ };
45209
+ };
45210
+ const warmWhole = async (target, signal, startedMs) => {
45211
+ const counted = await readBlocks(WHOLE_MODES.count, target, signal);
45212
+ if (counted * BLOCK_MIB2 > deps.capMib) {
45213
+ return { kind: "overCap", scope: "whole", blocks: counted };
45202
45214
  }
45203
- return { scope: "whole", blocks: await readBlocks(WHOLE_MODES.count, target, signal) };
45215
+ const read = await readBlocks(WHOLE_MODES.warm, target, signal);
45216
+ return {
45217
+ kind: "warmed",
45218
+ scope: "whole",
45219
+ blocks: read,
45220
+ scopeBlocks: counted,
45221
+ warmMs: Math.round(performance.now() - startedMs)
45222
+ };
45204
45223
  };
45205
45224
  const runWarm = async (target, signal) => {
45206
45225
  const startedMs = performance.now();
45207
45226
  try {
45208
- const counted = await countBlocks(target, signal);
45209
- if (counted.blocks * BLOCK_MIB2 > deps.capMib) {
45210
- return { kind: "overCap", scope: counted.scope, blocks: counted.blocks };
45227
+ if (existsSync21(target.blockList)) {
45228
+ try {
45229
+ return await warmRecorded(target, signal, startedMs);
45230
+ } catch (error) {
45231
+ signal.throwIfAborted();
45232
+ getImpdLogger("imps").with({ imp: target.name }).warning("the recorded blocks of the memory file cannot be read, so the whole file is: {error}", { error: getErrorMessage(error) });
45233
+ }
45211
45234
  }
45212
- const modes = counted.scope === "recorded" ? RECORDED_MODES : WHOLE_MODES;
45213
- const read = await readBlocks(modes.warm, target, signal);
45214
- return {
45215
- kind: "warmed",
45216
- scope: counted.scope,
45217
- blocks: read,
45218
- warmMs: Math.round(performance.now() - startedMs)
45219
- };
45235
+ return await warmWhole(target, signal, startedMs);
45220
45236
  } catch (error) {
45221
45237
  return { kind: "failed", error: getErrorMessage(error) };
45222
45238
  }
@@ -45274,15 +45290,15 @@ function createMemoryWarm(deps) {
45274
45290
  }
45275
45291
  };
45276
45292
  }
45277
- function isBlockListMode(mode) {
45278
- return mode === "--count-blocks" || mode === "--warm-blocks";
45279
- }
45280
45293
  function logWarm(target, outcome, capMib) {
45281
45294
  const logger = getImpdLogger("imps").with({ imp: target.name });
45282
45295
  match23(outcome).with({ kind: "warmed", scope: "recorded" }, (warmed) => {
45283
- logger.info("warmed {blocks} recorded blocks of the memory file in {warmMs}ms", {
45296
+ logger.info("warmed {blocks} of {recordedBlocks} recorded blocks ({blocksMib} of {recordedMib} MiB) in {warmMs}ms", {
45284
45297
  warmMs: String(warmed.warmMs),
45285
- blocks: String(warmed.blocks)
45298
+ blocks: String(warmed.blocks),
45299
+ recordedBlocks: String(warmed.scopeBlocks),
45300
+ blocksMib: String(warmed.blocks * BLOCK_MIB2),
45301
+ recordedMib: String(warmed.scopeBlocks * BLOCK_MIB2)
45286
45302
  });
45287
45303
  }).with({ kind: "warmed", scope: "whole" }, (warmed) => {
45288
45304
  logger.info("warmed the whole memory file in {warmMs}ms: {blocks} blocks of 2 MiB", {
@@ -45290,7 +45306,7 @@ function logWarm(target, outcome, capMib) {
45290
45306
  blocks: String(warmed.blocks)
45291
45307
  });
45292
45308
  }).with({ kind: "overCap", scope: "recorded" }, (over) => {
45293
- logger.info("left the memory file cold: its {dataMib} MiB of recorded blocks pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
45309
+ logger.info("left the memory file cold: not one of its {blocks} recorded blocks of {blockMib} MiB fits the warm cap of {capMib} MiB", { blocks: String(over.blocks), blockMib: String(BLOCK_MIB2), capMib: String(capMib) });
45294
45310
  }).with({ kind: "overCap", scope: "whole" }, (over) => {
45295
45311
  logger.info("left the memory file cold: its {dataMib} MiB of data pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
45296
45312
  }).with({ kind: "ended" }, (ended) => {
@@ -61247,6 +61263,7 @@ var WarmRunSchema = z105.object({
61247
61263
  mode: z105.enum(["--count-data", "--warm", "--count-blocks", "--warm-blocks"]),
61248
61264
  memFile: z105.string(),
61249
61265
  blockList: z105.string().optional(),
61266
+ limit: z105.int().optional(),
61250
61267
  pid: z105.int()
61251
61268
  });
61252
61269
  function createStubUffdHandler(directory, mode = "serve") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "7.10.0",
3
+ "version": "7.11.0",
4
4
  "description": "A real impd on stand-ins, for Bun tests of code that drives impd through @impz/client",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "ts-pattern": "^5.9.2",
48
48
  "xstate": "^5.33.3",
49
49
  "zod": "^4.6.7",
50
- "@impz/client": "7.10.0"
50
+ "@impz/client": "7.11.0"
51
51
  },
52
52
  "engines": {
53
53
  "bun": ">=1.4.3"