Skip to content
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

Limit deep stack growth #4156

Merged
merged 27 commits into from
Dec 6, 2024
Merged

Limit deep stack growth #4156

merged 27 commits into from
Dec 6, 2024

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Nov 27, 2024

R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
- Keep around the first deep stack trace; it may have useful
  information. (We may want to change this in the future to
  keep the first two stack traces, or even make it an option)
- Print out an indicator that we've elided stack traces, and
  how many
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
jcheng5 and others added 2 commits December 3, 2024 14:13
Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
@jcheng5 jcheng5 marked this pull request as ready for review December 4, 2024 08:52
R/conditions.R Outdated Show resolved Hide resolved
This hopefully will avoid any potential ..stacktraceon../off..
scoring issues, and will be more useful for users. The downside
is that it's still possible to have uselessly large deep stack
traces, but at least that will only happen now if you have
manually written gigantic async/promise chains by hand or maybe
did some clever metaprogramming. The coro case should be fine.
@jcheng5
Copy link
Member Author

jcheng5 commented Dec 5, 2024

After an in-person discussion with @cpsievert and @gadenbuie yesterday, we decided to use a different approach to limiting deep stack growth: rather than dropping deep stacks beyond a certain number, we only keep unique call stacks (determined by comparing digest(algo="md5") of the getCallNames()). This works great for both coro async iterators and (less so) recursive promise chains, as you really only want one of each unique call stack anyway.

Currently, we're simply keeping the first unique of each call stack. It would also be conceivable to limit the culling to consecutive duplicates, or to open up slightly from that and detect consecutive duplicate series of call stacks (for example, A B C A B would be OK, but if you try to append another C the result becomes A B C).

R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
@jcheng5 jcheng5 requested review from cpsievert and removed request for cpsievert December 5, 2024 20:20
@jcheng5
Copy link
Member Author

jcheng5 commented Dec 5, 2024

@cpsievert @gadenbuie was this too paranoid? d4f144d

@jcheng5 jcheng5 requested a review from cpsievert December 5, 2024 20:34
R/conditions.R Outdated Show resolved Hide resolved
R/conditions.R Outdated Show resolved Hide resolved
@cpsievert
Copy link
Collaborator

cpsievert commented Dec 5, 2024

@cpsievert @gadenbuie was this too paranoid? d4f144d

It does seem like overkill if we're just hashing character vectors, but if we end up doing something like #4156 (comment), then it seems worth doing.

R/conditions.R Outdated Show resolved Hide resolved
jcheng5 and others added 2 commits December 5, 2024 17:29
Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
@jcheng5 jcheng5 merged commit 79ee256 into main Dec 6, 2024
12 checks passed
@jcheng5 jcheng5 deleted the deep-stack-limit branch December 6, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants