eyeprolog 1.6.10 → 1.6.11

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.
package/bin/eyeprolog.js CHANGED
@@ -1,5 +1,22 @@
1
1
  #!/usr/bin/env node
2
- import { main } from '../src/cli.js';
2
+ import module from 'node:module';
3
+
4
+ // Reuse V8's compilation of the engine between runs. Starting the CLI compiles
5
+ // the whole reasoner before it can answer anything, which dominates the cost of
6
+ // a short query -- the shape most command-line use has. The cache makes that
7
+ // compilation a one-off rather than a per-invocation charge.
8
+ //
9
+ // src/cli.js is imported dynamically on purpose: static imports are evaluated
10
+ // before this module's body runs, so a static one would already have been
11
+ // compiled by the time the cache was enabled.
12
+ //
13
+ // enableCompileCache is Node 22.1+, hence the optional call for the supported
14
+ // Node 18 floor. It reports failure through a return value rather than
15
+ // throwing, and Node honours NODE_DISABLE_COMPILE_CACHE, so an unwritable or
16
+ // unwanted cache directory simply leaves startup as it was.
17
+ module.enableCompileCache?.();
18
+
19
+ const { main } = await import('../src/cli.js');
3
20
 
4
21
  await main(process.argv.slice(2)).catch((error) => {
5
22
  console.error(`eyeprolog: ${error && error.message ? error.message : String(error)}`);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.10",
6
+ "version": "1.6.11",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/platform.js CHANGED
@@ -43,6 +43,12 @@ export function usedHeapSize() {
43
43
  const oldGeneration = oldGenerationUsedSize();
44
44
  if (oldGeneration != null) return oldGeneration;
45
45
  }
46
+ // v8.getHeapStatistics().used_heap_size reports the same quantity as
47
+ // process.memoryUsage().heapUsed, but memoryUsage() additionally computes
48
+ // RSS, which costs a syscall, and allocates a result object. The solver
49
+ // polls this on a fixed inference interval, so the cheaper reading is
50
+ // worth preferring; memoryUsage stays as the fallback.
51
+ if (typeof v8?.getHeapStatistics === 'function') return v8.getHeapStatistics().used_heap_size;
46
52
  return process.memoryUsage().heapUsed;
47
53
  }
48
54
  const memory = globalThis.performance?.memory;