-
Notifications
You must be signed in to change notification settings - Fork 0
Windows: Docker vs. WSL speed test
Which solution is faster when analyzing data in Windows: Docker or Windows Linux Subsystem? Here is a test using LESYMAP and ANTsR. This is the same analysis performed with example(lesymap)
.
For the new updated test on WSL2, go to the bottom of the page.
The test was conducted on a laptop, the computer was restarted before the test. The antivirus was stopped. Docker and WSL were each tested in isolation, the competing solution was not active when testing each of them. The computer was not used for anything else during the tests.
The docker solution was tested through the available RStudio GUI.
The WSL solution was tested in command line (no GUI) and no graphic computations were performed.
A for loop was used to run 10 identical analyses as follows:
lesydata = file.path(find.package('LESYMAP'),'extdata')
filenames = Sys.glob(file.path(lesydata, 'lesions', 'Subject*.nii.gz'))
behavior = Sys.glob(file.path(lesydata, 'behavior', 'behavior.txt'))
runtime = rep(NA,10)
for (i in 1:10) runtime[i] = system.time(lesymap(filenames, behavior, method = 'BMfast'))['elapsed']
After the test finished, the runtime
values were exported with dput(runtime)
.
Values indicate seconds.
# docker container
runtimeDOCKER = c(61.875, 53.622, 56.961, 55.859, 54.273, 54.482, 52.918, 55.779, 52.006, 54.552)
# WSL
runtimeWSL = c(87.46, 81.784, 84.053, 84.092, 84.048, 84.421, 84.0429999999999, 83.89, 84.074, 84.5139999999999)
> data = data.frame(docker=runtimeDOCKER, wsl=runtimeWSL)
> summary(data)
docker wsl
Min. :52.01 Min. :81.78
1st Qu.:53.78 1st Qu.:84.04
Median :54.52 Median :84.06
Mean :55.23 Mean :84.24
3rd Qu.:55.84 3rd Qu.:84.34
Max. :61.88 Max. :87.46
> slower = mean(data$wsl - data$docker)/mean(data$docker) * 100
> print(paste0('WSL needs ', round(slower,0), '% more time than the docker solution.'))
[1] "WSL needs 53% more time than the docker solution."
Ubuntu on WSL needs 53% more time than a docker container to run the same LESYMAP example. What exactly takes more time was not investigated; could be the filesystem, the access to the CPU, the access to memory, etc. The WSL solution did not use RStudio either, therefore there was no graphic processing to hinder processing. Microsoft is working on an improved WSL version, called WSL 2, but for now WSL is not fast enough to compare with docker containers. In WSL, the user must install and update ANTsR, and it might be a struggle to make RStudio work properly, while the docker container has all these tools ready to go in a faster solution (both from an installation and from a processing perspective).
OS Name Microsoft Windows 10 Pro
Version 10.0.18362 Build 18362
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name LESIONTABLET5
System Manufacturer Microsoft Corporation
System Model Surface Pro
System Type x64-based PC
System SKU Surface_Pro_1796
Processor Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz, 2496 Mhz, 2 Core(s), 4 Logical Processor(s)
BIOS Version/Date Microsoft Corporation 234.2706.768, 4/18/2019
Docker software v.2.1.0.4 (39773), Engine 19.03.4
Docker software settings: 2 CPUs assigned, 3584Mb of memory
Docker image: dorianps/lesymap:20191107 DIGEST:sha256:ecda5b2bd101faec53465f1b4cb7e0d1f895ab69f096cf655170013774c95b49
Using R3.6.1 with latest ANTsR/LESYMAP as of Nov 7, 2019 (installed via devtools)
Fresh install of Ubuntu 18.04 from Microsoft Store, and updated in full with apt-get update && apt-get upgrade
.
Using R3.6.1 with latest ANTsR/LESYMAP as of Nov 7, 2019 (installed via devtools)
I ran the same test using WSL2, which is currently available only through advanced preview via Windows Insider. The expected release of WSL2 is April-May 2020. The test was run on a desktop with I7-2600K (overclocked at 4.4Ghz).
# docker container (Windows Docker 2.2.0.4 - 43472, R v3.6.1)
runtimeDOCKER = c(48.165, 47.572, 49.842, 47.367, 49.562, 47.091, 49.44, 47.028, 49.468, 47.067)
# WSL2 (Ubuntu 18.04, R v3.6.3, ran via v1.2.5033)
runtimeWSL2 = c(48.148, 47.749, 47.354, 46.628, 47.351, 46.025, 45.464, 44.923, 44.783, 45.511)
> data = data.frame(docker=runtimeDOCKER, wsl2=runtimeWSL2)
> summary(data)
docker wsl2
Min. :47.03 Min. :44.78
1st Qu.:47.16 1st Qu.:45.48
Median :47.87 Median :46.33
Mean :48.26 Mean :46.39
3rd Qu.:49.46 3rd Qu.:47.35
Max. :49.84 Max. :48.15
> slower = mean(data$wsl - data$docker)/mean(data$docker) * 100
> print(paste0('WSL needs ', round(slower,0), '% more time than the docker solution.'))
[1] "WSL needs -4% more time than the docker solution."
OS Name Microsoft Windows 10 Pro
Version 10.0.19041 Build 19041
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Manufacturer System manufacturer
System Model System Product Name
System Type x64-based PC
System SKU To be filled by O.E.M.
Processor Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz, 3401 Mhz, 4 Core(s), 8 Logical Processor(s)
WSL2 has a similar performance to docker.
This means that you can use WSL2 and Docker without losing performance with neither of them. However, setting up and maintaining a local Linux in WSL2 requires time and patience (it took me some hours to make RStudio work in WSL2/Ubuntu 18.04). Do not forget that WSL2 is a local installation, not a reproducible environment. Analyses run in WSL2 will be tied to the version of the libraries and software you have installed. Docker gives a full container that can be used for reproducible data analyses. In short, WSL2 can be useful for ad-hoc single-user local data processing, while Docker can be useful for massive deployment and collaborative data processing (i.e., two users or computers will be able to use the same identical environment). Both types of work can now be done with similar performance speed.