Skip to content

perf: parallelize terraform module analysis#54

Merged
RoseSecurity merged 2 commits intomainfrom
optimize
Feb 25, 2026
Merged

perf: parallelize terraform module analysis#54
RoseSecurity merged 2 commits intomainfrom
optimize

Conversation

@RoseSecurity
Copy link
Owner

Why

Summary

  • Parallelize Terraform module analysis across CPU cores using a bounded worker pool with goroutines, channels, and a semaphore
  • Merge FindTFDirs and FindFiles into a single ScanRepository function that walks the filesystem once instead of twice
  • Expand and unify the directory skip list (adding .terragrunt-cache, node_modules) so irrelevant subtrees are pruned early via filepath.SkipDir

Benchmarks

Stage Wall time CPU Speedup
Before 937ms 60%
+ parallel workers 450ms 220% 2.1x
+ single walk & skip list 365ms 279% 2.6x

Test plan

  • go build ./... passes
  • go vet ./... passes
  • Verified output matches pre-change results on the same repository
  • Test on a large multi-module Terraform repository to validate parallel speedup scales

- Replace sequential directory walking with worker pool pattern
- Merge FindTFDirs and FindFiles into single ScanRepository function
- Use runtime.NumCPU() to limit concurrent goroutines
- Add .terragrunt-cache and node_modules to skip list
- Reduce filesystem traversals from two passes to one
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@RoseSecurity RoseSecurity merged commit 20822dd into main Feb 25, 2026
3 of 4 checks passed
@RoseSecurity RoseSecurity deleted the optimize branch February 25, 2026 21:00
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.

2 participants