Conversation
|
A 10x improvement in creation! PR:
I adjusted the earlier profiling to not include promise_all as that was it's own bug at the time. n <- 100 * 1000
profvis::profvis({
message("Create")
proms <- lapply(seq_len(n), promise_resolve)
message("Execute")
while (!later::loop_empty()) {
later::run_now()
}
message("Done!")
})
|
* main: feat: Add `hybrid_then()` for flexible sync/async handling (#192)
|
Am going to merge to let shinycoreci run later tonight. |
|
I just took a quick look. I think in general it can make sense to replace R6 classes with environments when speed matters. I've done that a number of times myself, for example in fastmap: https://github.com/r-lib/fastmap/blob/main/R/fastmap.R In the case of promises, I think probably the biggest challenge is if someone has code that uses inheritance from For measuring performance, I suggest also benchmarking the overhead of S3 dispatch from I have a feeling that if you profile promises in real-world use, the time spent in promise creation will barely show up compared to other things in the lifecycle of a promise -- but I don't know for sure, so that's why it's worth getting data on it. |
|
I realized that the |
Completes #169 by @schloerke with the help of Claude Code.
The only addition here is to make
privateaccessible fromself(mimicking R6 internals) so that we don't break code/packages which reach into Promise internals. This would include my PR #190.I've run revdepchecks and they come in clean.
The above profiling consistently returns in 10-12s on my Macbook compared to 16-18s previously. This suggests that the optimization is not insignificant. @wlandau you're also welcome to comment based on your real life usage.