sparkforensics-mcp 0.2.4 → 0.4.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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -1
  3. package/bin/sparkforensics-mcp.mjs +41 -10
  4. package/package.json +1 -1
  5. package/vendor-core/analyzer.js +156 -48
  6. package/vendor-core/check-coverage.js +88 -0
  7. package/vendor-core/cli/budgets.js +31 -18
  8. package/vendor-core/cli/collect-run.js +76 -31
  9. package/vendor-core/cli/native-zstd.js +2 -2
  10. package/vendor-core/cli/threshold-config.js +28 -0
  11. package/vendor-core/comparison-verdict.js +177 -0
  12. package/vendor-core/core-source-hash.txt +1 -0
  13. package/vendor-core/core-usage-locality.js +56 -2
  14. package/vendor-core/detector-docs.js +58 -0
  15. package/vendor-core/detectors.js +933 -459
  16. package/vendor-core/docs-config.js +0 -36
  17. package/vendor-core/docs-content/chapters/nav-index.json +31 -0
  18. package/vendor-core/docs-content/detection/cstor.md +9 -0
  19. package/vendor-core/docs-content/detection/fail.md +6 -2
  20. package/vendor-core/docs-site-config.js +3 -0
  21. package/vendor-core/event-handlers.js +191 -6
  22. package/vendor-core/event-schemas.js +29 -0
  23. package/vendor-core/evidence-report.js +440 -112
  24. package/vendor-core/export-data.js +79 -6
  25. package/vendor-core/finding-action-label.js +9 -88
  26. package/vendor-core/finding-filter-predicate.js +9 -0
  27. package/vendor-core/finding-generic-recommendation.js +6 -104
  28. package/vendor-core/finding-names.js +21 -45
  29. package/vendor-core/finding-presentation.js +333 -0
  30. package/vendor-core/finding-tag-help.js +110 -0
  31. package/vendor-core/finding-types.js +361 -0
  32. package/vendor-core/findings-of-type.js +11 -0
  33. package/vendor-core/format-utils.js +92 -27
  34. package/vendor-core/html-export.js +51 -0
  35. package/vendor-core/impact-band.js +21 -8
  36. package/vendor-core/impact-estimator.js +8 -521
  37. package/vendor-core/impact-format.js +114 -0
  38. package/vendor-core/impact-model.js +175 -0
  39. package/vendor-core/ingest.js +2 -0
  40. package/vendor-core/intervals.js +13 -0
  41. package/vendor-core/list-runs.js +2 -3
  42. package/vendor-core/load-vendored.js +70 -5
  43. package/vendor-core/mcp-server-factory.js +14 -10
  44. package/vendor-core/mcp-tools.js +105 -45
  45. package/vendor-core/model-assembler.js +12 -0
  46. package/vendor-core/occupancy.js +1 -1
  47. package/vendor-core/parser-worker.js +22 -5
  48. package/vendor-core/plan-graph-model.js +3 -2
  49. package/vendor-core/plan-node-detail.js +1 -1
  50. package/vendor-core/recommendation-rollup.js +63 -3
  51. package/vendor-core/redact.js +68 -28
  52. package/vendor-core/run-comparison.js +40 -7
  53. package/vendor-core/run-interpretation.js +290 -0
  54. package/vendor-core/run-outcome.js +74 -0
  55. package/vendor-core/run-payload.js +17 -0
  56. package/vendor-core/run-shape.js +40 -0
  57. package/vendor-core/run-verdict.js +353 -0
  58. package/vendor-core/scaling-sim.js +4 -5
  59. package/vendor-core/scorecard-estimates.js +62 -0
  60. package/vendor-core/shs-fetch.js +175 -65
  61. package/vendor-core/shs-load.js +1 -1
  62. package/vendor-core/sql-stages.js +11 -0
  63. package/vendor-core/stage-quantiles.js +14 -0
  64. package/vendor-core/task-failure.js +151 -0
  65. package/vendor-core/threshold-overrides.js +160 -0
  66. package/vendor-core/threshold-summary.js +11 -33
  67. package/vendor-core/types.js +6 -42
  68. package/vendor-core/vendor/fflate.js +1 -1
  69. package/vendor-core/wall-clock.js +1 -12
  70. package/vendor-core/wasted-core-hours.js +2 -2
  71. package/vendor-core/zip-archive.js +167 -0
@@ -1,5 +1,3 @@
1
- import { detectorCatalog } from './detectors.js';
2
-
3
1
  // Single source of the docs-panel URL surface. DOCS_BASE_DIR is the built docs-site path that
4
2
  // serves the tuning reference, relative to the app's origin.
5
3
  export const DOCS_BASE_DIR = 'docs/tuning-reference';
@@ -90,40 +88,6 @@ export function isKnownDocAnchor(anchor ) {
90
88
  return KNOWN_DOC_ANCHORS.has(String(anchor));
91
89
  }
92
90
 
93
- // Finding types that never appear as their own DETECTORS entry's type: the parent entry declares
94
- // a different type because one plan-walk covers two rules (see broadcastSizing). Map to the parent.
95
- const TYPE_ALIASES = {
96
- underBroadcast: 'broadcastSizing',
97
- overBroadcast: 'broadcastSizing',
98
- };
99
-
100
- // DETECTORS is static, so this grouping is built once (lazily) instead of re-scanning per
101
- // docAnchorForType call (called once per TagBadge per render).
102
- let anchorsByTypeCache ;
103
-
104
- function anchorsByType() {
105
- if (!anchorsByTypeCache) {
106
- anchorsByTypeCache = new Map();
107
- for (const entry of detectorCatalog()) {
108
- const anchors = anchorsByTypeCache.get(entry.type) ?? new Set();
109
- anchors.add(entry.docAnchor);
110
- anchorsByTypeCache.set(entry.type, anchors);
111
- }
112
- }
113
- return anchorsByTypeCache;
114
- }
115
-
116
- /** Resolves a finding `type` to its documented anchor from detectorCatalog(). Returns undefined
117
- * when entries sharing the type disagree on docAnchor (only configAudit today), or when the
118
- * resolved anchor isn't in the allowlist (isKnownDocAnchor, the same gate DocsLink uses). */
119
- export function docAnchorForType(type ) {
120
- const resolvedType = TYPE_ALIASES[type] ?? type;
121
- const anchors = anchorsByType().get(resolvedType) ?? new Set();
122
- if (anchors.size !== 1) return undefined;
123
- const [anchor] = anchors;
124
- return anchor && isKnownDocAnchor(anchor) ? anchor : undefined;
125
- }
126
-
127
91
  /** The docAnchor every finding in `findings` carries, or undefined when they disagree or any lacks
128
92
  * one. For a badge standing for several findings (a widget header, a grouped row) whose type-level
129
93
  * docAnchorForType can't pick one: configAudit's sub-checks each stamp their own anchor. */
@@ -3,6 +3,7 @@
3
3
  "anchor": "intro",
4
4
  "section": "Getting Started",
5
5
  "title": "Introduction",
6
+ "brief": "Guide overview: what the reference covers, the severity-dot legend, and the tag system linking into the Bottleneck Reference.",
6
7
  "keywords": [
7
8
  "severity-dot",
8
9
  "tag-system"
@@ -14,6 +15,7 @@
14
15
  "anchor": "spark-architecture",
15
16
  "section": "Optimization Guide",
16
17
  "title": "Spark Execution Model",
18
+ "brief": "Spark's execution model: Driver/Executor split, DAGScheduler/TaskScheduler roles, stage boundaries at shuffles, and pipelining of narrow transformations.",
17
19
  "keywords": [
18
20
  "driver-executor",
19
21
  "dagscheduler",
@@ -27,6 +29,7 @@
27
29
  "anchor": "memory-model",
28
30
  "section": "Optimization Guide",
29
31
  "title": "Memory Management",
32
+ "brief": "Unified memory management: on-heap/off-heap execution vs. storage regions, spill triggers, and executor memory overhead sizing.",
30
33
  "keywords": [
31
34
  "unified-memory",
32
35
  "execution-memory",
@@ -41,6 +44,7 @@
41
44
  "anchor": "partitioning",
42
45
  "section": "Optimization Guide",
43
46
  "title": "Partitioning",
47
+ "brief": "Partition sizing and reshaping: repartition vs. coalesce mechanics, shuffle-partition tuning, and skew detection thresholds.",
44
48
  "keywords": [
45
49
  "repartition",
46
50
  "coalesce",
@@ -53,6 +57,7 @@
53
57
  "anchor": "joins",
54
58
  "section": "Optimization Guide",
55
59
  "title": "Join Optimization",
60
+ "brief": "Physical join strategy selection: broadcast vs. shuffle joins, join hints, bucketing, and AQE's runtime join-strategy switching.",
56
61
  "keywords": [
57
62
  "broadcast",
58
63
  "shuffle-join",
@@ -66,6 +71,7 @@
66
71
  "anchor": "shuffle",
67
72
  "section": "Optimization Guide",
68
73
  "title": "Shuffle",
74
+ "brief": "Shuffle internals: SortShuffleManager mechanics, shuffle-avoidance paths (bucketing, Storage Partition Join), and shuffle-tuning configs.",
69
75
  "keywords": [
70
76
  "sortshufflemanager",
71
77
  "bucketing",
@@ -78,6 +84,7 @@
78
84
  "anchor": "data-formats",
79
85
  "section": "Optimization Guide",
80
86
  "title": "Data Formats",
87
+ "brief": "Columnar file format tradeoffs: Parquet vs. ORC internals, splittability, predicate pushdown, and compression codec choice.",
81
88
  "keywords": [
82
89
  "parquet",
83
90
  "orc",
@@ -91,6 +98,7 @@
91
98
  "anchor": "table-formats",
92
99
  "section": "Optimization Guide",
93
100
  "title": "Table Formats",
101
+ "brief": "Lakehouse table-format tuning across Delta Lake, Iceberg, and Hudi: file sizing, compaction/OPTIMIZE, clustering (Z-order/liquid/sort), metadata and manifest overhead, snapshot/version expiry, and deletion vectors vs. merge-on-read/copy-on-write.",
94
102
  "keywords": [
95
103
  "delta",
96
104
  "iceberg",
@@ -107,6 +115,7 @@
107
115
  "anchor": "caching",
108
116
  "section": "Optimization Guide",
109
117
  "title": "Caching & Persistence",
118
+ "brief": "cache()/persist() semantics, storage levels, eviction behavior, and checkpointing as a lineage-truncation alternative.",
110
119
  "keywords": [
111
120
  "cache",
112
121
  "persist",
@@ -120,6 +129,7 @@
120
129
  "anchor": "pyspark",
121
130
  "section": "Optimization Guide",
122
131
  "title": "PySpark Specifics",
132
+ "brief": "PySpark-specific performance: UDF serialization cost, Arrow-optimized and pandas UDF types, and Python-worker memory configs.",
123
133
  "keywords": [
124
134
  "udf",
125
135
  "arrow",
@@ -133,6 +143,7 @@
133
143
  "anchor": "aqe",
134
144
  "section": "Optimization Guide",
135
145
  "title": "Adaptive Query Execution",
146
+ "brief": "AQE's runtime re-optimization loop: post-shuffle partition coalescing, join-strategy promotion, and skew-partition splitting.",
136
147
  "keywords": [
137
148
  "partition-coalescing",
138
149
  "join-strategy-promotion",
@@ -145,6 +156,7 @@
145
156
  "anchor": "cluster-config",
146
157
  "section": "Optimization Guide",
147
158
  "title": "Cluster Tuning",
159
+ "brief": "Cluster-level sizing: executor core/memory formulas, container memory budgeting, dynamic allocation, and locality-wait tuning.",
148
160
  "keywords": [
149
161
  "executor-sizing",
150
162
  "container-memory",
@@ -158,6 +170,7 @@
158
170
  "anchor": "anti-patterns",
159
171
  "section": "Optimization Guide",
160
172
  "title": "Anti-Patterns",
173
+ "brief": "Checklist of a dozen recurring Spark performance anti-patterns, each with what it is, how to detect it, why it hurts, and how to fix it.",
161
174
  "keywords": [
162
175
  "checklist",
163
176
  "anti-pattern"
@@ -169,6 +182,7 @@
169
182
  "anchor": "bottleneck-skew",
170
183
  "section": "Detector Catalog",
171
184
  "title": "Task Skew",
185
+ "brief": "Detecting and mitigating task skew: oversized shuffle partitions vs. the median, AQE skew-join splitting, and manual salting as the pre-AQE fallback.",
172
186
  "keywords": [
173
187
  "skew",
174
188
  "aqe-skew-join",
@@ -181,6 +195,7 @@
181
195
  "anchor": "bottleneck-shuffle",
182
196
  "section": "Detector Catalog",
183
197
  "title": "Shuffle I/O",
198
+ "brief": "Detecting and mitigating shuffle I/O bottlenecks: read/write byte thresholds, fetch-wait time, and shuffle-avoidance and tuning levers.",
184
199
  "keywords": [
185
200
  "shuffle-bytes",
186
201
  "fetch-wait"
@@ -192,6 +207,7 @@
192
207
  "anchor": "bottleneck-spill",
193
208
  "section": "Detector Catalog",
194
209
  "title": "Memory / Disk Spill",
210
+ "brief": "Detecting and mitigating memory/disk spill: TaskMemoryManager pressure, the skew-vs-volume spill classification, and matching the fix to the cause.",
195
211
  "keywords": [
196
212
  "spill",
197
213
  "taskmemorymanager"
@@ -203,6 +219,7 @@
203
219
  "anchor": "bottleneck-gc",
204
220
  "section": "Detector Catalog",
205
221
  "title": "GC Pressure",
222
+ "brief": "Detecting and mitigating GC pressure: the gcPct warning/critical thresholds, oversized executors and memory.fraction as causes, and off-heap/collector fixes.",
206
223
  "keywords": [
207
224
  "gc-pressure",
208
225
  "memory-fraction",
@@ -215,6 +232,7 @@
215
232
  "anchor": "bottleneck-cold-start",
216
233
  "section": "Detector Catalog",
217
234
  "title": "Cold Start",
235
+ "brief": "Detecting and mitigating cold start: the firstStageSubmittedAt gap before the first stage is submitted, and executor-sizing/dynamic-allocation readiness fixes.",
218
236
  "keywords": [
219
237
  "cold-start",
220
238
  "dynamic-allocation"
@@ -226,6 +244,7 @@
226
244
  "anchor": "bottleneck-utilization",
227
245
  "section": "Detector Catalog",
228
246
  "title": "Executor Utilization",
247
+ "brief": "Detecting and mitigating low executor utilization: the avg/peak active-executor ratio, under-partitioning and coalesce-caused parallelism loss, and dynamic-allocation over-provisioning.",
229
248
  "keywords": [
230
249
  "executor-utilization",
231
250
  "under-partitioning",
@@ -238,6 +257,7 @@
238
257
  "anchor": "bottleneck-slow-host",
239
258
  "section": "Detector Catalog",
240
259
  "title": "Slow Host",
260
+ "brief": "Detecting and mitigating a slow host: host-wide task duration inflation versus the cluster median, and speculative-execution or locality-wait fixes.",
241
261
  "keywords": [
242
262
  "slow-host",
243
263
  "speculative-execution"
@@ -249,6 +269,7 @@
249
269
  "anchor": "bottleneck-failures",
250
270
  "section": "Detector Catalog",
251
271
  "title": "Task Failures",
272
+ "brief": "Detecting and mitigating task failures: the TaskEndReason taxonomy, failed-task-share thresholds, and distinguishing memory-driven ExecutorLostFailure from application-code ExceptionFailure.",
252
273
  "keywords": [
253
274
  "taskendreason",
254
275
  "executorlostfailure",
@@ -261,6 +282,7 @@
261
282
  "anchor": "bottleneck-straggler",
262
283
  "section": "Detector Catalog",
263
284
  "title": "Stragglers",
285
+ "brief": "Detecting and mitigating straggler tasks: the 4x-median-duration rule, distinguishing stragglers from GC pauses or skew, and speculative-execution tuning.",
264
286
  "keywords": [
265
287
  "straggler",
266
288
  "speculative-execution"
@@ -272,6 +294,7 @@
272
294
  "anchor": "bottleneck-retry-waste",
273
295
  "section": "Detector Catalog",
274
296
  "title": "Retry Waste",
297
+ "brief": "Detecting and mitigating wasted retry compute: executorRunTime burned by superseded task attempts, and distinguishing executor-loss from fetch-failure causes.",
275
298
  "keywords": [
276
299
  "retry-waste",
277
300
  "fetch-failure"
@@ -283,6 +306,7 @@
283
306
  "anchor": "bottleneck-tiny-tasks",
284
307
  "section": "Detector Catalog",
285
308
  "title": "Tiny Tasks",
309
+ "brief": "Detecting and mitigating tiny-task overhead: scheduling/serialization cost dominating once partitions shrink too far, and coalesce/repartition sizing fixes.",
286
310
  "keywords": [
287
311
  "tiny-tasks",
288
312
  "scheduling-overhead"
@@ -294,6 +318,7 @@
294
318
  "anchor": "bottleneck-job-failure-rate",
295
319
  "section": "Detector Catalog",
296
320
  "title": "Job Failure Rate",
321
+ "brief": "Detecting and mitigating job-level failure: the task/stage/executor retry-budget escalation ladder that turns isolated failures into an aborted job.",
297
322
  "keywords": [
298
323
  "job-failure-rate",
299
324
  "retry-budget"
@@ -305,6 +330,7 @@
305
330
  "anchor": "bottleneck-memory-utilization",
306
331
  "section": "Detector Catalog",
307
332
  "title": "Memory Utilization",
333
+ "brief": "Detecting and mitigating held-but-idle executor memory: cores sitting idle below allocated slots, dynamic-allocation idle timeouts that reclaim an executor's memory band, and the low-confidence peak-vs-allocated waste estimate.",
308
334
  "keywords": [
309
335
  "memory-utilization",
310
336
  "idle-timeout"
@@ -316,6 +342,7 @@
316
342
  "anchor": "bottleneck-duplicate-plan-subtree",
317
343
  "section": "Detector Catalog",
318
344
  "title": "Duplicate Plan Subtree",
345
+ "brief": "Detecting a repeated scan or exchange subtree in a physical plan, how exchange reuse and cache()/persist() avoid recomputing it, and why inferring duplication from the plan is a medium-confidence signal.",
319
346
  "keywords": [
320
347
  "duplicate-plan-subtree",
321
348
  "exchange-reuse"
@@ -327,6 +354,7 @@
327
354
  "anchor": "bottleneck-small-files",
328
355
  "section": "Detector Catalog",
329
356
  "title": "Small Files",
357
+ "brief": "Detecting and mitigating the small-files problem on read and write: metadata and I/O overhead of many tiny files, and coalesce()/repartition()/compaction and AQE advisoryPartitionSizeInBytes as output-size controls.",
330
358
  "keywords": [
331
359
  "small-files",
332
360
  "advisorypartitionsizeinbytes"
@@ -338,6 +366,7 @@
338
366
  "anchor": "bottleneck-broadcast-sizing",
339
367
  "section": "Detector Catalog",
340
368
  "title": "Broadcast Sizing",
369
+ "brief": "Detecting under- and over-broadcast joins: spark.sql.autoBroadcastJoinThreshold and its default, when to broadcast the smaller side versus shuffle, and the driver-collection and executor-memory failure modes of broadcasting too large a table.",
341
370
  "keywords": [
342
371
  "broadcast-threshold",
343
372
  "driver-collection"
@@ -349,6 +378,7 @@
349
378
  "anchor": "metrics",
350
379
  "section": "Reference",
351
380
  "title": "Metrics Glossary",
381
+ "brief": "Glossary of every metric surfaced elsewhere on the site: what each one measures, its event-log source field, and what a problematic value looks like.",
352
382
  "keywords": [
353
383
  "metrics-glossary",
354
384
  "event-log"
@@ -360,6 +390,7 @@
360
390
  "anchor": "config",
361
391
  "section": "Reference",
362
392
  "title": "Spark Config Quick-Reference",
393
+ "brief": "Cross-reference of the Spark/PySpark config properties and JVM GC flags discussed elsewhere in the guide, with defaults and version notes.",
363
394
  "keywords": [
364
395
  "spark-config",
365
396
  "gc-flags"
@@ -2,3 +2,12 @@
2
2
 
3
3
  A persisted dataset is not fully cached in memory, or is spilling to disk.
4
4
  Raise executor memory, or shrink the cached dataset.
5
+
6
+ The cached-partition counts and sizes come from `SparkListenerBlockUpdated`
7
+ events, which Spark writes only when
8
+ `spark.eventLog.logBlockUpdates.enabled=true`. Since Spark 2.3 the RDD
9
+ storage figures in stage-submission events are always 0, and they are
10
+ used only as a fallback. When a Spark 2.3+ run persists RDDs but its log has
11
+ neither and block-update logging was off, the check reports that the cache could not be
12
+ checked instead of passing it: turn `spark.eventLog.logBlockUpdates.enabled`
13
+ on and rerun to measure eviction and disk spillover.
@@ -1,5 +1,9 @@
1
1
  ### `FAIL`: Failed tasks {#fail}
2
2
 
3
3
  Tasks fail often enough to affect the stage. Failed tasks point to executor
4
- instability or data-driven errors: check driver logs for the dominant
5
- failure reason.
4
+ instability or data-driven errors. The finding names the dominant error: the
5
+ exception class, or the executor loss reason (for example "Container killed
6
+ by YARN for exceeding memory limits"). It lists up to five distinct failures,
7
+ each with its message and a short stack excerpt. With redaction on, messages
8
+ and the message text inside excerpts are replaced, since they can carry file
9
+ paths and data values; class names and stack frames stay.
@@ -14,3 +14,6 @@ import { typeTag } from './format-utils.js';
14
14
  export function findingGuideUrl(type ) {
15
15
  return `docs/user-guide/understanding-findings.html#${typeTag(type).toLowerCase()}`;
16
16
  }
17
+
18
+ // Every other way to get a log (cloud consoles, bastions, copying from storage).
19
+ export const ALTERNATIVE_LOG_RETRIEVAL_URL = 'docs/user-guide/alternative-log-retrieval.html';