Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the prior commit I looked into why R overhead was so high for future calls. The marginal cost of a foreign call to Python is only 3ms, but for R this was 70ms. I found this improved 2-3 fold by setting globals=FALSE in the `future` call. This tells `future` not to search global variables to pass to the new R instances. Using the multicore plan, a fork of the original R program is made for each new worker, the workers may be reused when they complete their jobs. With every new job, they may need to the latest global information. `future` will search for that information is `globals=TRUE`. Otherwise, the original global variables are retained (e.g., all the functions defined in pool.R). Assuming no new globals are defined by jobs, which they should not be, this choice should be safe. In this commit, I've benchmarked the change: +------------------+---------------+-------------+-------------+ | benchmark | globals=FALSE | msgpack | v0 | +------------------+---------------+-------------+-------------+ | cZeroBaseline | 54.1 ± 1.5 | 53 ± 1.6 | 44 ± 4.5 | | pZeroBaseline | 96.8 ± 3.5 | 94 ± 3.2 | 82 ± 4.0 | | pZeroFromForeign | 100.2 ± 1.4 | 99 ± 1.5 | 89 ± 6.7 | | pZeroToForeign | 101.3 ± 3.2 | 98 ± 2.7 | 90 ± 5.7 | | rZeroBaseline | 580.1 ± 6.2 | 678 ± 8.1 | 312 ± 5.5 | | rZeroFromForeign | 568.6 ± 3.2 | 672 ± 5.1 | 345 ± 11.9 | | rZeroToForeign | 571.4 ± 4.5 | 660 ± 3.3 | 335 ± 6.6 | +------------------+---------------+-------------+-------------+ | cTenBaseline | 79.7 ± 3.2 | 79 ± 1.8 | 98 ± 5.7 | | pTenBaseline | 126.3 ± 4.1 | 125 ± 3.2 | 133 ± 4.9 | | pTenFromForeign | 706.5 ± 172 | 809 ± 160 | 2232 ± 49 | | pTenToForeign | 509.0 ± 3.5 | 495 ± 3.9 | 2041 ± 44 | | rTenBaseline | 1266.8 ± 2.9 | 1356 ± 9.2 | 1099 ± 34 | | rTenFromForeign | 1333.8 ± 122 | 1527 ± 125 | 4191 ± 418 | | rTenToForeign | 1538.6 ± 4.8 | 1646 ± 22 | 3529 ± 144 | +------------------+---------------+-------------+-------------+ | rMarginalCost1 | 581.7 ± 7.0 | 680 ± 4.9 | 328 ± 7.9 | | rMarginalCost2 | 621.9 ± 2.9 | 774 ± 6.6 | 637 ± 22 | | rMarginalCost3 | 668.7 ± 18.5 | 863 ± 5.7 | 931 ± 55 | | rMarginalCost4 | 737.9 ± 12.1 | 1050 ± 2.7 | 1221 ± 38 | | pMarginalCost1 | 108.0 ± 0.9 | 107 ± 0.9 | 88 ± 4.4 | | pMarginalCost2 | 114.9 ± 1.4 | 114 ± 1.7 | 124 ± 4.1 | | pMarginalCost3 | 119.2 ± 1.7 | 117 ± 1.9 | 166 ± 4.9 | | pMarginalCost4 | 122.4 ± 0.7 | 120 ± 0.7 | 214 ± 11 | +------------------+---------------+-------------+-------------+ | pMap1000 | 2.7 | 2.68 ± 0.04 | 47.0 ± 5.1 | | rMap1000 | 23.8 | 70.0 | - | +------------------+---------------+-------------+-------------+
- Loading branch information