Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixing 'stack level too deep error' in commits_in_tag#936

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

douglasmiller
Copy link
Contributor

Fixes the issueoutlined here.

Thecommits_in_tag method was using a recursive solution to iterate over the entire graph of commits. This caused astack level too deep error when a sufficiently large number of commits exist in the repository. This solution will produce the same results without the need for recursion/stack usage.

I also observed that thecommits_in_tag method was being called multiple times for the same SHA and was very inefficient. I made a couple of optimizations which make use of a cache of already processed SHAs.

Baseline

real1m1.836suser1m1.283ssys0m0.257s

Adding@commits_in_tag_cache

real0m45.565suser0m29.704ssys0m0.430s

Reversingtags infetch_tag_shas and using@commits_in_tag_cache

real0m22.471suser0m7.947ssys0m0.416s

ameir reacted with hooray emoji
Copy link
Collaborator

@olleolleolleolleolleolle left a comment

Choose a reason for hiding this comment

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

Yes!

♥️ 💛 💚 💙 💜

# Fetch all SHAs occurring in or before a given tag and add them to
# "shas_in_tag"
#
# @param [Array] tags The array of tags.
# @return [Nil] No return; tags are updated in-place.
def fetch_tag_shas(tags)
tags.each do |tag|
tag["shas_in_tag"] = commits_in_tag(tag["commit"]["sha"])
# Reverse the tags array to gain max benefit from the @commits_in_tag_cache
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for leaving this code comment here, guiding other readers.

@olleolleolleolleolleolle merged commitf218bc7 intogithub-changelog-generator:masterFeb 19, 2021
@olleolleolle
Copy link
Collaborator

Ha, I was hasty, but we have circled the issue more, now: perhaps you get a clue by these notes?

Fetching events for issues and PR: 465Fetching closed dates for issues: 465/465Traceback (most recent call last):7: from /Users/olle/.rvm/gems/ruby-2.7.1/gems/async-1.28.9/lib/async/task.rb:265:in `block in make_fiber'6: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/generator/generator.rb:55:in `block in compound_changelog'5: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/generator/generator.rb:152:in `fetch_issues_and_pr'4: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/generator/generator_fetcher.rb:48:in `add_first_occurring_tag_to_prs'3: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/generator/generator_fetcher.rb:65:in `associate_tagged_prs'2: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/octo_fetcher.rb:353:in `fetch_tag_shas'1: from /Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/octo_fetcher.rb:353:in `reverse_each'/Users/olle/opensource/github-changelog-generator/lib/github_changelog_generator/octo_fetcher.rb:354:in `block in fetch_tag_shas': undefined method `[]' for nil:NilClass (NoMethodError)

@douglasmiller
Copy link
ContributorAuthor

Gah! In the last minute, I changed how thetag keys were accessed to make it easier to write tests. I initially tested thecommits_in_tag method directly, but moved it to a private method at the end and had to adjust the testing strategy. I feel silly for not running the script again to ensure that it was still working properly 😳.

@olleolleolle
Copy link
Collaborator

Hey, thanks for taking the time to measure speed, to fix the thing, to change it to working!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@olleolleolleolleolleolleolleolleolle approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@douglasmiller@olleolleolle

[8]ページ先頭

©2009-2025 Movatter.jp