Skip to content

Improves bundle performance by parallelization and utilizing new single walk function in GAF - #161

Draft
z4ce wants to merge 3 commits into
snyk:mainfrom
z4ce:bundle_performance
Draft

Improves bundle performance by parallelization and utilizing new single walk function in GAF#161
z4ce wants to merge 3 commits into
snyk:mainfrom
z4ce:bundle_performance

Conversation

@z4ce

@z4ce z4ce commented Jul 16, 2026

Copy link
Copy Markdown

Description

Companion PR: snyk/go-application-framework#657
This PR is in relation to this ticket. My testing shows that the changes here reduce bundle creation time from between %50 to %90. Feel free to take whatever you want from this PR and remix it with whatever design might suite engineering better.

I broke these improvements into two commits. The first just uses the single walk from the GAF. I didn't benchmark separately, but for most repos this where the lion's share of performance improvement comes from. The second commit parallelizes the bundle creation. Feel free to pick choose or remix as engineering sees fit.

Checklist

  • Tests added and all succeed
  • Linted
  • README.md updated, if user-facing

🚨After having merged, please update the snyk-ls and CLI go.mod to pull in latest client.

z4ce and others added 2 commits July 16, 2026 16:20
Replace the two-pass file discovery (GetAllFiles followed by
GetFilteredFiles) with GetFilteredFilesSingleWalk, which traverses the
project tree once and prunes ignored directories (e.g. node_modules,
.git) instead of walking the whole tree and glob-matching every file
underneath them. That traversal was the dominant cost on real projects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Process files with a pool of workers when creating a bundle. The
per-file work (stat, read, hash) is I/O-bound and independent across
files, so oversubscribing the CPUs keeps the disk busy while syscalls
block — this matters most on Windows, where per-file syscalls are
comparatively expensive. Results are merged under a mutex, and the
lazy filter load is guarded so concurrent workers fetch filters exactly
once. Each file is opened a single time and stat'd via the open handle
to avoid a redundant filesystem lookup.

Also deduplicate the UTF-8 conversion in BundleFileFrom: the content is
now converted once and reused for both the hash and the bundle content,
via the new util.HashContent helper, instead of converting twice.

Add a benchmark covering bundle creation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@z4ce
z4ce force-pushed the bundle_performance branch from 9441270 to a5bb6fd Compare July 16, 2026 06:49
@snyk-io

snyk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ Snyk checks are incomplete.

Status Scan Engine Critical High Medium Low Total (0)
⚠️ Open Source Security 0 0 0 0 See details
⚠️ Licenses 0 0 0 0 See details
Code Security 0 0 0 0 0 issues
Secrets 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io

snyk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ Snyk checks are incomplete.

Status Scan Engine Critical High Medium Low Total (0)
⚠️ Open Source Security 0 0 0 0 See details
⚠️ Licenses 0 0 0 0 See details
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment thread go.mod Outdated
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Signed-off-by: Felix Sargent <felix.sargent@snyk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants