-
-
Notifications
You must be signed in to change notification settings - Fork 848
Avoid processing a single commit multiple times #1058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smortex
wants to merge
1
commit into
github-changelog-generator:master
Choose a base branch
from
smortex:avoid-processing-a-single-commit-multiple-time
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Avoid processing a single commit multiple times #1058
smortex
wants to merge
1
commit into
github-changelog-generator:master
from
smortex:avoid-processing-a-single-commit-multiple-time
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The repo in question: https://github.com/OpenVoxProject/openvox-agent
|
kenyon
reviewed
May 31, 2025
When listing the commits that appear in a tag, some commits are added multiple time to the resulting Set. As a Set cannot contain duplicate, this is only a waste of computing resources, but with large repositories with a lot of branches and merges, this can require a tremendous amount of time. To illustrate the issue, consider the following git history with 5 commits: ``` A---B---C---D \ / E ``` Assuming A is the root commit, and we call `commits_in_tag(D)`. Let's inspect the value of `shas` and `queue` at the beginning of the loop, and what is pushed to these variables on each iteration: 1. `shas = {}; queue = [D] #=> shas << D; queue << C` 2. `shas = {D}; queue = [C] #=> shas << C; queue << [B, E]` 3. `shas = {D, C}; queue = [B, E] #=> shas << B; queue << A` 4. `shas = {D, C, B}; queue = [E, A] #=> shas << E; queue << B` 5. `shas = {D, C, B, E}; queue = [A, B] #=> shas << A` 6. `shas = {D, C, B, E, A}; queue = [B] #=> shas << B; queue << A` 7. `shas = {D, C, B, E, A}; queue = [A] #=> shas << A` 8. `shas = {D, C, B, E, A}; queue = [] #=> exit loop` As you can see above, 6 and 7 attempt to add B and A to the set, but they where already added at step 3 and 5, so these action are no-op. This change checks if the current commit is already present in `shas`, and if so skip to the next queued commit. The above example becomes: 1. `shas = {}; queue = [D] #=> shas << D; queue << C` 2. `shas = {D}; queue = [C] #=> shas << C; queue << [B, E]` 3. `shas = {D, C}; queue = [B, E] #=> shas << B; queue << A` 4. `shas = {D, C, B}; queue = [E, A] #=> shas << E; queue << B` 5. `shas = {D, C, B, E}; queue = [A, B] #=> shas << A` 6. `shas = {D, C, B, E, A}; queue = [B] #=> next` 7. `shas = {D, C, B, E, A}; queue = [] #=> exit loop` While we where previously unable to generate the ChangeLog of one of our projects in a reasonable amount of time (Ctrl+C after 15+ minutes of waiting at 100% CPU), this change allows us to generate it in ~45s on my laptop.
4fa93b7
to
a0344af
Compare
smortex
added a commit
to OpenVoxProject/puppet
that referenced
this pull request
Jun 3, 2025
For the record, the changelog was generated with [this commit of github-changelog-generator](github-changelog-generator/github-changelog-generator#1058). While not stricktly necessary, it happens that other non-released merged PR where not added to the ChangeLog with the latest release.
smortex
added a commit
to OpenVoxProject/puppet
that referenced
this pull request
Jun 3, 2025
For the record, the changelog was generated with [this commit of github-changelog-generator](github-changelog-generator/github-changelog-generator#1058). It happens that other non-released merged PR where not added to the ChangeLog with the latest release.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When listing the commits that appear in a tag, some commits are added multiple time to the resulting Set. As a Set cannot contain duplicate, this is only a waste of computing resources, but with large repositories with a lot of branches and merges, this can require a tremendous amount of time.
To illustrate the issue, consider the following git history with 5 commits:
Assuming A is the root commit, and we call
commits_in_tag(D)
. Let's inspect the value ofshas
andqueue
at the beginning of the loop, and what is pushed to these variables on each iteration:shas = {}; queue = [D] #=> shas << D; queue << C
shas = {D}; queue = [C] #=> shas << C; queue << [B, E]
shas = {D, C}; queue = [B, E] #=> shas << B; queue << A
shas = {D, C, B}; queue = [E, A] #=> shas << E; queue << B
shas = {D, C, B, E}; queue = [A, B] #=> shas << A
shas = {D, C, B, E, A}; queue = [B] #=> shas << B; queue << A
shas = {D, C, B, E, A}; queue = [A] #=> shas << A
shas = {D, C, B, E, A}; queue = [] #=> exit loop
As you can see above, 6 and 7 attempt to add B and A to the set, but they where already added at step 3 and 5, so these action are no-op.
This change checks if the current commit is already present in
shas
, and if so skip to the next queued commit. The above example becomes:shas = {}; queue = [D] #=> shas << D; queue << C
shas = {D}; queue = [C] #=> shas << C; queue << [B, E]
shas = {D, C}; queue = [B, E] #=> shas << B; queue << A
shas = {D, C, B}; queue = [E, A] #=> shas << E; queue << B
shas = {D, C, B, E}; queue = [A, B] #=> shas << A
shas = {D, C, B, E, A}; queue = [B] #=> next
shas = {D, C, B, E, A}; queue = [] #=> exit loop
While we where previously unable to generate the ChangeLog of one of our projects in a reasonable amount of time (Ctrl+C after 15+ minutes of waiting at 100% CPU), this change allows us to generate it in ~45s on my laptop.