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

speed up package version check in .rlang_cli_compat() #1657

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

simonpcouch
Copy link
Contributor

I recently came across a slowdown when profiling some tidymodels code that I thought might be worth raising. The utils::packageVersion("rlang") >= "0.4.2" check in standalone-cli.R adds up for us downstream.

With rlang 1.1.1:

bench::mark(
  signal = rlang::signal(class = "boop"),
  group_by = dplyr::group_by(mtcars, cyl),
  check = FALSE
)
#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 signal        276µs    288µs     3393.  296.68KB     16.8
#> 2 group_by      860µs    900µs     1080.    3.49MB     16.8

With this PR:

#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 signal       46.1µs   47.8µs    20399.  294.26KB     32.0
#> 2 group_by    572.5µs  604.7µs     1603.    3.48MB     23.2

I believe this should be compatible with the "standalone" approach but feels a bit more hacky than I'd usually be comfortable submitting. Very much open to iterate. :)

@lionel- lionel- merged commit 7a78dc3 into r-lib:main Oct 7, 2023
12 checks passed
@lionel-
Copy link
Member

lionel- commented Oct 7, 2023

Thanks! The other thing you could do is cache the information in a top-level object namespaced with the compat prefix.

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