@danielsimonjr/mathts-parallel 0.2.2 → 0.3.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/dist/index.d.ts +24 -5
- package/dist/index.js +9 -4
- package/package.json +57 -57
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,22 @@ interface ComputePoolConfig {
|
|
|
72
72
|
/** Default task timeout in milliseconds */
|
|
73
73
|
taskTimeout: number;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Default per-op thresholds derived from benchmark data (tools/benchmark/parallel/run.ts,
|
|
77
|
+
* 2026-05-23). Values measured on a noisy CI container — re-run on target hardware to retune.
|
|
78
|
+
*
|
|
79
|
+
* 'never' → Number.MAX_SAFE_INTEGER (benchmark showed no reliable speedup)
|
|
80
|
+
* 'always' → 0 (always parallelize when pool is ready)
|
|
81
|
+
* number → minimum element count before dispatching to workers
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Canonical, benchmark-tuned per-op parallelization thresholds. This is the
|
|
85
|
+
* single source of truth consulted by `ComputePool.shouldParallelize` — the
|
|
86
|
+
* authority the typed functions actually dispatch through. The coarser
|
|
87
|
+
* category-level {@link ThresholdDispatcher} derives its overlapping values
|
|
88
|
+
* (e.g. matmul) from here so the two cannot silently diverge.
|
|
89
|
+
*/
|
|
90
|
+
declare const DEFAULT_THRESHOLD_BY_OP: Partial<Record<OpName, OpThreshold>>;
|
|
75
91
|
/**
|
|
76
92
|
* Default ComputePool configuration
|
|
77
93
|
*/
|
|
@@ -1179,11 +1195,14 @@ interface ThresholdConfig {
|
|
|
1179
1195
|
general: number;
|
|
1180
1196
|
}
|
|
1181
1197
|
/**
|
|
1182
|
-
* Default thresholds
|
|
1198
|
+
* Default category-level thresholds.
|
|
1183
1199
|
*
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1200
|
+
* NOTE: `ComputePool.shouldParallelize` (op-level, {@link DEFAULT_THRESHOLD_BY_OP})
|
|
1201
|
+
* is the authority the typed functions dispatch through. This category map is a
|
|
1202
|
+
* coarser helper; where a category overlaps a tuned op (matmul) its value is
|
|
1203
|
+
* derived from the canonical const so the two cannot diverge. The remaining
|
|
1204
|
+
* categories (no single ComputePool op equivalent — many are 'never') keep
|
|
1205
|
+
* heuristic defaults for compute-vs-memory-bound work.
|
|
1187
1206
|
*/
|
|
1188
1207
|
declare const DEFAULT_THRESHOLDS: ThresholdConfig;
|
|
1189
1208
|
/**
|
|
@@ -1283,4 +1302,4 @@ interface PoolStats {
|
|
|
1283
1302
|
activeTasks: number;
|
|
1284
1303
|
}
|
|
1285
1304
|
|
|
1286
|
-
export { type BitwiseBinaryOp, type ChunkInfo, type ChunkOptions, type ChunkResult, ComputePool, type ComputePoolConfig, DEFAULT_POOL_CONFIG, DEFAULT_THRESHOLDS, type DispatchResult, type ElementwiseOptions, type ExecOptions, type ExecutionMode, type MapOptions, type MatmulOptions, type OpName, type OpThreshold, type OperationCategory, type ParallelResult, type PoolOptions, type PoolStats, type ReduceOptions, type ThresholdConfig, ThresholdDispatcher, bitAnd, bitNot, bitOr, bitXor, calculateChunks, calculateOptimalChunks, chunkArray, chunkFloat64Array, computePool, dispatch, leftShift, mergeArrayChunks, mergeFloat64Chunks, parallelAbs, parallelAdd, parallelCos, parallelCount, parallelDistance, parallelDivide, parallelDot, parallelElementwise, parallelEvery, parallelExp, parallelFilter, parallelFind, parallelForEach, parallelHistogram, parallelLog, parallelMap, parallelMatmul, parallelMatvec, parallelMax, parallelMean, parallelMin, parallelMinMax, parallelMultiply, parallelNegate, parallelNorm, parallelOuter, parallelReduce, parallelScale, parallelSin, parallelSome, parallelSort, parallelSqrt, parallelSquare, parallelStd, parallelSubtract, parallelSum, parallelTan, parallelTranspose, parallelUnary, parallelVariance, partition2D, partitionRange, resolveOpThreshold, rightArithShift, rightLogShift, shouldParallelize$1 as shouldChunkParallelize, shouldParallelize, thresholdDispatcher };
|
|
1305
|
+
export { type BitwiseBinaryOp, type ChunkInfo, type ChunkOptions, type ChunkResult, ComputePool, type ComputePoolConfig, DEFAULT_POOL_CONFIG, DEFAULT_THRESHOLDS, DEFAULT_THRESHOLD_BY_OP, type DispatchResult, type ElementwiseOptions, type ExecOptions, type ExecutionMode, type MapOptions, type MatmulOptions, type OpName, type OpThreshold, type OperationCategory, type ParallelResult, type PoolOptions, type PoolStats, type ReduceOptions, type ThresholdConfig, ThresholdDispatcher, bitAnd, bitNot, bitOr, bitXor, calculateChunks, calculateOptimalChunks, chunkArray, chunkFloat64Array, computePool, dispatch, leftShift, mergeArrayChunks, mergeFloat64Chunks, parallelAbs, parallelAdd, parallelCos, parallelCount, parallelDistance, parallelDivide, parallelDot, parallelElementwise, parallelEvery, parallelExp, parallelFilter, parallelFind, parallelForEach, parallelHistogram, parallelLog, parallelMap, parallelMatmul, parallelMatvec, parallelMax, parallelMean, parallelMin, parallelMinMax, parallelMultiply, parallelNegate, parallelNorm, parallelOuter, parallelReduce, parallelScale, parallelSin, parallelSome, parallelSort, parallelSqrt, parallelSquare, parallelStd, parallelSubtract, parallelSum, parallelTan, parallelTranspose, parallelUnary, parallelVariance, partition2D, partitionRange, resolveOpThreshold, rightArithShift, rightLogShift, shouldParallelize$1 as shouldChunkParallelize, shouldParallelize, thresholdDispatcher };
|
package/dist/index.js
CHANGED
|
@@ -1483,11 +1483,15 @@ async function parallelCount(data, predicate, options = {}) {
|
|
|
1483
1483
|
}
|
|
1484
1484
|
|
|
1485
1485
|
// src/strategies/threshold.ts
|
|
1486
|
+
function opThreshold(op, fallback) {
|
|
1487
|
+
const raw = DEFAULT_THRESHOLD_BY_OP[op];
|
|
1488
|
+
return typeof raw === "number" ? raw : fallback;
|
|
1489
|
+
}
|
|
1486
1490
|
var DEFAULT_THRESHOLDS = {
|
|
1487
|
-
matmul:
|
|
1488
|
-
//
|
|
1491
|
+
matmul: opThreshold("matmul", 4096),
|
|
1492
|
+
// canonical: DEFAULT_THRESHOLD_BY_OP.matmul
|
|
1489
1493
|
elementwise: 5e4,
|
|
1490
|
-
// ~50K elements
|
|
1494
|
+
// ~50K elements (memory-bound; ComputePool ops mostly 'never')
|
|
1491
1495
|
reduce: 1e5,
|
|
1492
1496
|
// ~100K elements
|
|
1493
1497
|
map: 1e4,
|
|
@@ -1495,7 +1499,7 @@ var DEFAULT_THRESHOLDS = {
|
|
|
1495
1499
|
sort: 5e3,
|
|
1496
1500
|
// ~5K elements
|
|
1497
1501
|
decomposition: 2500,
|
|
1498
|
-
// ~50x50 matrix
|
|
1502
|
+
// ~50x50 matrix (no single canonical op; heuristic)
|
|
1499
1503
|
general: 5e4
|
|
1500
1504
|
// Default ~50K
|
|
1501
1505
|
};
|
|
@@ -1608,6 +1612,7 @@ export {
|
|
|
1608
1612
|
ComputePool,
|
|
1609
1613
|
DEFAULT_POOL_CONFIG,
|
|
1610
1614
|
DEFAULT_THRESHOLDS,
|
|
1615
|
+
DEFAULT_THRESHOLD_BY_OP,
|
|
1611
1616
|
ThresholdDispatcher,
|
|
1612
1617
|
Transfer,
|
|
1613
1618
|
bitAnd,
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@danielsimonjr/mathts-parallel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "WebWorker parallelization for MathTS computations",
|
|
5
|
-
"author": "Daniel Simon Jr.",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"README.md"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean",
|
|
23
|
-
"dev": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --watch",
|
|
24
|
-
"test": "vitest run",
|
|
25
|
-
"test:watch": "vitest",
|
|
26
|
-
"test:coverage": "vitest run --coverage",
|
|
27
|
-
"typecheck": "tsc --noEmit",
|
|
28
|
-
"lint": "eslint src --ext .ts",
|
|
29
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
30
|
-
"clean": "rm -rf dist",
|
|
31
|
-
"build:prod": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean --minify --treeshake"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@danielsimonjr/mathts-workerpool": "^0.2.0"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@types/node": "^25.5.2",
|
|
38
|
-
"tsup": "^8.0.0",
|
|
39
|
-
"typescript": "^5.3.0",
|
|
40
|
-
"vitest": "^4.1.5"
|
|
41
|
-
},
|
|
42
|
-
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
},
|
|
45
|
-
"repository": {
|
|
46
|
-
"type": "git",
|
|
47
|
-
"url": "https://github.com/danielsimonjr/mathts",
|
|
48
|
-
"directory": "parallel"
|
|
49
|
-
},
|
|
50
|
-
"keywords": [
|
|
51
|
-
"math",
|
|
52
|
-
"typescript",
|
|
53
|
-
"parallel",
|
|
54
|
-
"webworker",
|
|
55
|
-
"worker-pool"
|
|
56
|
-
]
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielsimonjr/mathts-parallel",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "WebWorker parallelization for MathTS computations",
|
|
5
|
+
"author": "Daniel Simon Jr.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean",
|
|
23
|
+
"dev": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --watch",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"test:coverage": "vitest run --coverage",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint src --ext .ts",
|
|
29
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"build:prod": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean --minify --treeshake"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@danielsimonjr/mathts-workerpool": "^0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^25.5.2",
|
|
38
|
+
"tsup": "^8.0.0",
|
|
39
|
+
"typescript": "^5.3.0",
|
|
40
|
+
"vitest": "^4.1.5"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/danielsimonjr/mathts",
|
|
48
|
+
"directory": "parallel"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"math",
|
|
52
|
+
"typescript",
|
|
53
|
+
"parallel",
|
|
54
|
+
"webworker",
|
|
55
|
+
"worker-pool"
|
|
56
|
+
]
|
|
57
|
+
}
|