Gilead-BioStats / gsm

Good Statistical Monitoring R Package
https://gilead-biostats.github.io/gsm/
Apache License 2.0
39 stars 9 forks source link

Feature: Reduce render time of Flags Over Time module in report. #1879

Closed samussiah closed 1 month ago

samussiah commented 1 month ago

Feature Details

With more and more snapshots the flags over time table takes a long time to render. Would be good to figure out how to speed up the process.

Example Code

Possible Implementation

Additional Comments

jonthegeek commented 1 month ago

Unfortunately the slow-down is deep inside {gt}, specifically in gt:::dt_styles_set() (inside gt::data_color(), which is called by our data_color_rag()). That's the function that actually sets up colors once everything has been figured out about where colors go, so nothing we can do in front of that will speed things up noticeably.

I think our only option would be to subset the data, for example to only include rows that have ever had flags. On my machine, rendering the report with all of reportingResults went from 37.54s to 2.83 seconds with this filter:

    dplyr::filter(
      dplyr::if_any(dplyr::all_of(date_cols), ~!is.na(.x) & .x != 0)
    )
jonthegeek commented 1 month ago

Getting rid of the background coloration DRAMATICALLY sped things up. See next PR.

jonthegeek commented 1 month ago

Oops meant to close the PR.