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

perf: Replace superseded dplyr::recode() #1927

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Conversation

mgirlich
Copy link
Contributor

@mgirlich mgirlich commented Jul 12, 2023

Using superseded functions harms the performance quite a bit.
I noticed this when removing tables via dm::dm_select_tbl(dm, -any_of(tables_to_remove)).

data <- nycflights_subset()
flights <- data$flights
weather <- data$weather
airlines <- data$airlines
airports <- data$airports
planes <- data$planes

dm <- dm(airlines, airports, flights, planes, weather)

remove_tables <- function() {
  dm %>% 
    dm_select_tbl(-airlines) %>% 
    dm_select_tbl(-airports) %>% 
    dm_select_tbl(-flights) %>% 
    dm_select_tbl(-planes) %>% 
    dm_select_tbl(-weather)
}

bench::mark(
  remove_tables()
)

# Before
# # A tibble: 1 × 13
#   expression     min median `itr/sec` mem_alloc `gc/sec` n_itr
#   <bch:expr>  <bch:> <bch:>     <dbl> <bch:byt>    <dbl> <int>
# 1 remove_tab… 52.5ms 58.2ms      16.7    1.35MB     13.4     5

# After
# # A tibble: 1 × 13
#   expression     min median `itr/sec` mem_alloc `gc/sec` n_itr
#   <bch:expr>  <bch:> <bch:>     <dbl> <bch:byt>    <dbl> <int>
# 1 remove_tab… 15.8ms 17.3ms      55.2    55.3KB     12.6    22

@krlmlr krlmlr changed the title Replace superseded dplyr::recode() perf: Replace superseded dplyr::recode() Aug 14, 2023
@krlmlr krlmlr merged commit 44e4ed9 into cynkra:main Aug 14, 2023
2 checks passed
@krlmlr
Copy link
Collaborator

krlmlr commented Aug 14, 2023

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants