perf: reduce hot-path allocations and defer default env gating to scan [IDE-1786]#1207
Conversation
Consolidate config resolution and scan-state work, tighten OSS conversion, trim hover channel buffer, and wait for default env only in the delegating scanner so CLI initialization is not blocked. - ConfigResolver: single RLock and getBoolLocked for DisplayableIssueTypesForFolder - ScanStateAggregator: per-folder issue-type cache and pre-sized maps - OSS: byte prefix for JSON array detection; vulnerability index by ID; GetExtendedMessage takes resolved format string (fewer config lookups per issue) - Hover: reduce hover channel buffer from 10000 to 100 - Scanner: add preScanChecks; move WaitForDefaultEnv from CLI helpers to Scan - Benchmarks for config resolver, state snapshot, and UnmarshallOssJson UnmarshallOssJson errors now report input length instead of embedding the full payload in the error string.
|
/describe |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
PR Description updated to latest commit (d159d9e) |
This comment has been minimized.
This comment has been minimized.
Address PR review feedback: direct byte check res[0]=='[' could fail if CLI output contains leading whitespace or BOM. Use bytes.TrimLeft to strip whitespace before the check while remaining allocation-free.
This comment has been minimized.
This comment has been minimized.
| // so the tree builder can distinguish "not yet scanned" from "scan completed with 0 issues". | ||
| func (agg *ScanStateAggregator) productScanStates(stateMap scanStateMap) map[types.FilePath]map[product.Product]bool { | ||
| states := make(map[types.FilePath]map[product.Product]bool) | ||
| states := make(map[types.FilePath]map[product.Product]bool, len(stateMap)/4+1) |
There was a problem hiding this comment.
it is a best effort estimate for products :). it's not always the right size, but it's a start.
…rmance/improve-memory-cpu-usage
This comment has been minimized.
This comment has been minimized.
…rmance/improve-memory-cpu-usage
This comment has been minimized.
This comment has been minimized.
…rmance/improve-memory-cpu-usage
This comment has been minimized.
This comment has been minimized.
…rmance/improve-memory-cpu-usage
PR Reviewer Guide 🔍
|
User description
Description
This PR targets
refactor/IDE-1786_folder-config-refactoringand adds performance improvements identified from profiling (config resolution, scan state aggregation, OSS conversion, startup path).Behavioural notes
WaitForDefaultEnvruns inDelegatingConcurrentScannerbefore scans, not inSnykCli.getCommand/ extension executor — faster init, scans still wait for PATH/JAVA_HOME/Maven defaults.UnmarshallOssJsonerrors report input length instead of embedding the full payload (avoids huge error strings).Technical summary
RLock+getBoolLockedforDisplayableIssueTypesForFolderissuesByIDindex;GetExtendedMessage(format, ...)StateSnapshot,UnmarshallOssJsonChecklist
make generate)make lint-fix)PR Type
Enhancement, Tests
Description
Defer default environment readiness checks to scanner.
Optimize hot-path allocations and map pre-sizing.
Refine OSS JSON parsing and error reporting.
Introduce new benchmarks and tests.
File Walkthrough
4 files
Reduce hover channel buffer sizeOptimize scan state aggregation and cachingOptimize OSS JSON unmarshalling and error reportingOptimize config resolver with locked getter7 files
Add StateSnapshot benchmarkAdd tests for scanner env readiness handlingUpdate ExtensionExecutor env readiness testUpdate CLI getCommand env readiness testAdd UnmarshallOssJson benchmarkUpdate OSS tests for refactored issue conversionAdd config resolver benchmarks6 files
Defer default env check to scanner pre-scanRemove default env wait from CLI getCommandRemove default env wait from ExtensionExecutorRefactor OSS issue conversion logicSimplify GetExtendedMessage signatureAlign unified converter with GetExtendedMessage signature