-
-
Notifications
You must be signed in to change notification settings - Fork 849
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing 'stack level too deep error' in commits_in_tag #936
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
Ha, I was hasty, but we have circled the issue more, now: perhaps you get a clue by these notes?
|
Gah! In the last minute, I changed how the |
Hey, thanks for taking the time to measure speed, to fix the thing, to change it to working! |
Fixes the issue outlined here.
The
commits_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 the
commits_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
Adding
@commits_in_tag_cache
Reversing
tags
infetch_tag_shas
and using@commits_in_tag_cache