hashicorp / go-changelog

Changelog generation based on files in a directory.
Mozilla Public License 2.0
107 stars 20 forks source link

Traverse git log concurrently #18

Closed eculver closed 2 years ago

eculver commented 2 years ago

This is a follow-on to #17 for improving performance. In this part, I am refactoring the code to do the most expensive operation (traversing through the git log) inside a golang.org/x/sync/errgroup.Group which manages the work in group of goroutines executing concurrently. The entire repository is loaded into memory so there isn't contention in doing the git operations. I did have to implement a thread-safe EntryList for managing the list of changelog entries created along the way, but the coordination code is all handled by errgroup.Group which is pretty nice. Warning: this is my first time using this package, so I'm still a little curious if there are any gotchas with it to be found. So far it's been really nice to work with.

Note: I can't stack PRs without pushing to a remote on hashicorp/go-changelog and I don't have access to do that so I'll just have to get #17 merged first and then this change will only include the concurrency parts which can be merged separately.