Skip to content

Only generate the trace_back() as needed #177

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

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Nov 3, 2023

Follow up on #172

I was investigating tidyverse/dplyr#6897 with dev lifecycle installed and discovered a lot of the remaining time spent in repeated calls to deprecate_soft() and deprecate_warn() with always = FALSE is in generating the trace_back(), which we throw away every single time except for the very first one.

I've moved the trace_back() call after our early exit, which cuts the time for deprecate_soft() in half again

# trigger it once
lifecycle::deprecate_soft("1.1.0", "fn()", "fn2()")

f <- function() {
  lifecycle::deprecate_soft("1.1.0", "fn()", "fn2()")
}
g <- function() {
  for (i in 1:1000) {
    f()
  }  
}
bench::system_time(g())

Current dev main

process    real 
  712ms   703ms

This PR

process    real 
  385ms   379ms 

@DavisVaughan DavisVaughan requested a review from lionel- November 3, 2023 20:47
@lionel- lionel- merged commit 691afac into main Nov 6, 2023
@lionel- lionel- deleted the feature/faster-deprecate-soft-warn branch November 6, 2023 11:57
@lionel-
Copy link
Member

lionel- commented Nov 6, 2023

Awesome, thanks!

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.

2 participants