i was asking myself if and how rstudio or r uses multiple cores of my cpu. researching brings up mostly topics from around ~2010,which suggest using parallel or other packages to achieve multicore usage.
If i monitor my cpu usage while running intense scripts (e.g. monte carlo simulations with "vectorized" drawing "processes" looping through different distributions) , all cores seem to be busy and increase in their usage.
so this implies multicore usage to a certain extend, my question is if this just looks like it and the process runs only on one core. I got an i7 7760U.
R can indeed make use of all cores available, but you need to explicitly tell it to do it because not all code can be run in parallel. There are a few great packages for implementation, but I think this blog can help you get started:
thank you for your quick reply.
as i try to focus on algebraic processes handling my data, your post might answer my question, how this "probably" multicore usage is achieved. So it seems parts of my script indeed take advantage of using more than one core.
So thanks a lot for clearing this up and kind regards,
Hi Chris,
Some additional background info.
Under Windows (and probably other OS too) the OS will distribute a single thread's work across the available cores so each core does a fraction of the work; this is invisible to the user. The most reliable way to tell whether you are getting more than one core's worth of performance is to check the total CPU usage: if it is more than 100/n% (where n is the number of cores) they you are getting a boost from parallel processing (multi-threading).
Base R is still mostly single-threaded, but @rstub mentions some notable exceptions.
If you explicitly use the parallel package under Windows, you'll see tasks named "RScript" for your workers in Task Manager, while your parallel tasks are running you should see each of these getting approx 100/n% of your CPU (e.g. 25% if you assign your tasks to 4 cores).
thanks for your reply, this supports parts of my asumptions!
So using mentioned packages could probably increase the already running multi core perfomance.