Skip to content

Conversation

@ZacBlanco
Copy link
Contributor

@wu-sheng wu-sheng added this to the 0.9.0 milestone Jan 14, 2026
@wu-sheng wu-sheng added the enhancement New feature or request label Jan 14, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds concurrent header checking to improve performance by processing files in parallel using goroutines and errgroup. The change updates the Check function to check license headers across files concurrently with a limit based on GOMAXPROCS.

Changes:

  • Introduced concurrent file processing using golang.org/x/sync/errgroup
  • Set concurrency limit to runtime.GOMAXPROCS(0)
  • Modified the file checking loop to spawn goroutines for parallel execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +49 to +57
g := new(errgroup.Group)
g.SetLimit(runtime.GOMAXPROCS(0))

for _, file := range fileList {
if err := CheckFile(file, config, result); err != nil {
return err
}
f := file
g.Go(func() error {
return CheckFile(f, config, result)
})
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Result struct methods (Succeed, Fail, Ignore) perform unsynchronized slice appends in concurrent goroutines, causing race conditions. The Result type (lines 32-42 in result.go) uses direct slice appends without any synchronization mechanism like sync.Mutex. This will lead to data races and potentially lost results or corrupted data when multiple goroutines write to the same Result instance simultaneously.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacBlanco Is this an issue?

Copy link
Contributor Author

@ZacBlanco ZacBlanco Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. I didn't look closely enough into the Result struct. I pushed a version which adds a mutex to make the Result struct's associated methods thread-safe. Accessing the inner slices directly is still not thread-safe but the code does not do anything with the slices directly while the concurrent checks are happening so I think it should be ok

@kezhenxu94 kezhenxu94 merged commit 0630b01 into apache:main Jan 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] skywalking-eyes check headers concurrently

3 participants