-
Notifications
You must be signed in to change notification settings - Fork 129
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
Dynamic branching slowness #1089
Comments
Let's try to pinpoint the bottleneck. Would you post some profiling data as a zip archive to this thread? Then, we can look at some flame graphs like in #1086 (comment). Different systems have different bottlenecks, so it is helpful to have profiling data directly from your system. (By the way, what OS and R version are you using?) library(drake)
list_of_data_frames <- list(...)
plan <- drake_plan(
# Let's try to isolate the slow part.
d_long_tobit = target(NULL, dynamic = map(list_of_data_frames))
)
Rprof(filename = "samples.rprof")
make(plan) # Do you see the same delay?
Rprof(NULL)
zip(zipfile = "samples.zip", files = "samples.rprof") # Upload samples.zip to this thread. I suspect the bottleneck is here: Line 275 in 687ee98
Specifically here: Lines 72 to 79 in 687ee98
When it comes time to register sub-targets, |
I'm using R 3.6.1 on Windows 10, and I'm running within the current RStudio desktop. Just counting the seconds, it took about 10 seconds before the first target was listed, and it took 16 seconds from the first target being listed to starting the first subtarget, and then it took a long time (16 minutes) to compute all of the subtargets. In my use case here, it takes a long time to calculate the results (minutes to hours) due to the large number of targets, but each individual target is relatively fast (seconds). I wonder if there could be some form of disk-write optimization where targets are written to disk when some (configurable) memory cache either fills (e.g. passes 128 MB) or some time duration passes (e.g. 10 minutes) or make exits? Here is the Rprof output: At a quick look, it does appear that you're right that most of the time is spent on file system work. Here is everything that took at least 10 seconds:
|
Most of the file-system-related slowness is probably due to richfitz/storr#116. Trying to solve that with richfitz/storr#117. I just pushed a couple commits to try to attack Otherwise, here is the overall landscape of runtime. You may some speed improvements if you disable history (5% runtime) progress (7%) logging to the console (7%) and prep for data recovery ( But all that is in the overwhelming 16 minutes of execution. To try to isolate that initial 26-second delay, I think we should try to force those sub-targets to fail instead of build. library(drake)
list_of_data_frames <- list(...)
plan <- drake_plan(
d_long_tobit = target(stop("sub-target"), dynamic = map(list_of_data_frames))
)
Rprof(filename = "samples.rprof")
try(make(plan)) # keep_going is FALSE by default, so this should stop early.
Rprof(NULL)
zip(zipfile = "samples.zip", files = "samples.rprof") What I suspect (but don't know for sure) is that You'll notice Other than that, it is a bit hard for me to tell what the bottlenecks are in |
I recently pushed several efficiency gains for To help with this issue, here is a self-contained reprex: library(drake)
data_for_half_life <-
lapply(
X=1:11000,
FUN=function(...) data.frame(a=rnorm(10), b=rnorm(10), c=rnorm(10), d=rnorm(10))
)
plan <- drake_plan(
# Let's try to isolate the slow part.
d_long_tobit = target(stop("sub-target"), dynamic = map(data_for_half_life))
)
Rprof(filename = "samples.rprof")
make(plan) # Do you see the same delay?
Rprof(NULL) And, here is the zip of the Rprof from that. |
Nice! You can also use |
Is it possible for |
Someday another format may surpass |
By the way, your example code really helps! I was able to reproduce and mitigate some of the same bottlenecks you are seeing. Care to try ed13af1? |
You cut half the time out! Using the example in #1089 (comment), I got this new Rprof result. |
Awesome! #1092 and eddelbuettel/digest@7d60b5b are likely to speed it up even more. |
We're good. Thank you! |
Prework
drake
's code of conduct.Proposal
I have a dynamic target with a list of ~11,000 data.frames that takes up ~16 MB. When it starts to build the dynamic target, it takes a bit of time (~10 seconds) for to move from the
dynamic d_long_tobit
line to the firstsubtarget d_long_tobit_b2a80233
. I assume that the time is taken to calculate a hash (b2a80233) of the target.Would it be possible to cache the hash calculation (as though it were another target) for the dynamic targets? (Or, am I wrong about where the time is going? I did a quick look into the code, but I got lost before I found my way to the hash calculation.)
The text was updated successfully, but these errors were encountered: