Skip to content

Conversation

@DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Sep 23, 2025

Pushed upstream in r-lib/rlang#1830

Used by r_dim(), r_class(), etc, which is in our deepest loops (size-common, ptype-common), so we want these helpers to be fully inlined.

In particular r_dim() was slower than Rf_getAttrib(x, R_DimSymbol) and would show up in Instruments profiling, and I don't want to have to decide between the two.

cross::bench_versions(
  pkgs = c(
    # Main before doing any of these PRs
    "r-lib/vctrs@0279470c6de6ee2db3a9b333c198754080554ee7",
    # Current main
    "r-lib/vctrs",
    # This PR
    "r-lib/vctrs#2039"
  ),
  fn = \() {
    library(vctrs)
    x <- as.list(1:1e6)
    bench::mark(list_unchop(x), iterations = 200)
  }
)
# A tibble: 3 × 14
  pkg           expression   min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time result
  <chr>         <bch:expr> <bch> <bch:>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm> <list>
1 r-lib/vctrs@… list_unch… 150ms  158ms      6.17    11.4MB     10.2   200   332      32.4s <int> 
2 r-lib/vctrs   list_unch… 141ms  150ms      6.52    11.4MB     10.8   200   332      30.7s <int> 
3 r-lib/vctrs#… list_unch… 140ms  147ms      6.64    11.4MB     11.0   200   332      30.1s <int> 
# ℹ 3 more variables: memory <list>, time <list>, gc <list>

@DavisVaughan DavisVaughan merged commit 57e48a1 into main Sep 23, 2025
14 checks passed
@DavisVaughan DavisVaughan deleted the feature/pairlist-inline branch September 23, 2025 17:53
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