@onimaxxing/worldgen 0.18.0 → 0.19.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.
package/index.js CHANGED
@@ -43,6 +43,20 @@ function _requireInit(method) {
43
43
  * @param {number | 'auto' | 'serial'} [opts.threads='auto'] `'serial'`
44
44
  * forces the serial build; a number sets an explicit rayon worker
45
45
  * count; `'auto'` uses `navigator.hardwareConcurrency`.
46
+ *
47
+ * This used to be clamped to 4, because stock dlmalloc takes one
48
+ * global lock and worldgen's layout/mob phases are allocation-heavy,
49
+ * so extra workers serialized on malloc: on a 16-thread host,
50
+ * M-FLIP-C-42 peaked at 2 workers (1.52x) and then went BACKWARDS,
51
+ * reaching 0.67x at 16 — slower than not threading at all.
52
+ *
53
+ * The parallel build now installs a thread-caching allocator
54
+ * (`oni_wasm::alloc_cache`), and scaling is monotonic again, so the
55
+ * clamp is gone. Same coord/host, measured: 304 ms at 1 worker ->
56
+ * 164 at 2 -> 97 at 4 -> 68 at 8 -> 65 at 16 (4.74x). Speedup is now
57
+ * bounded by the cluster's world-size distribution, not the
58
+ * allocator — a 1-world coord still only reaches ~1.4x because just
59
+ * the in-world noise stage is parallel.
46
60
  * @returns {Promise<void>}
47
61
  */
48
62
  async function init(opts) {
@@ -62,6 +76,8 @@ async function init(opts) {
62
76
  }
63
77
 
64
78
  if (wantParallel && typeof mod.initThreadPool === 'function') {
79
+ // No clamp — the thread-caching allocator restored monotonic
80
+ // scaling; see the `threads` doc above for the measurements.
65
81
  const threads = typeof opts?.threads === 'number'
66
82
  ? opts.threads
67
83
  : (globalThis.navigator?.hardwareConcurrency ?? 4);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@onimaxxing/worldgen",
3
3
  "type": "module",
4
4
  "description": "WASM entry point for ONI worldgen",
5
- "version": "0.18.0",
5
+ "version": "0.19.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
Binary file
Binary file