Docker Enables New Features, Dramatically Reduces File Sharing Time by 98%

Recently, Docker updated the desktop application on the macOS side, and introduced an experimental feature called VirtioFS in the new version. According to the official introduction, after this feature is turned on, the time spent on file sharing can be greatly reduced by 98%.

To understand why this feature has resulted in a significant performance improvement, it is necessary to first understand common developer workflows. A common workflow for developers working with technologies such as Symfony or React is to edit source code residing on a macOS host while running the application itself in a Docker container, with the source code being shared between the host and container using Docker data volumes.

Modifications to files located on the host system must therefore be synchronized to the container file system quickly and reliably. When considering that modern dependency management can easily bring tens of thousands of files into a project, the performance of file sharing will affect the performance of the entire system, and the current default gRPC-FUSE will lead to Poor performance.

Recent changes to Docker Desktop for Mac , especially the addition of support for VirtioFS, alleviate this problem and bring huge improvements to file system performance. Specifically, after enabling VirtioFS on Docker Desktop 4.6, the developers came up with the following results in testing:

  • Reduced the time required to complete a MariaDB import by 98% (from 33 minutes to 42 seconds)
  • 90% reduction in the time required to complete a 284MB MySQL import (from 3 minutes 16 seconds to 18 seconds);
  • 87% reduction in time to run composer installon (from 1 minute 27 seconds to 11 seconds);
  • 80% reduction in the time to start a monolithic Typescript application (from 1 minute 30 seconds to 18 seconds);

This change in the new version reduces the time to complete filesystem operations by up to 98%, and for developers, the huge speedup means less time waiting for filesystem operations to complete (or building special project-specific methods to improve performance) and have more time to focus on the development of the project.

How to enable VirtioFS

Note: VirtioFS is only available for users with the following macOS versions

  • macOS 12.2 and above (M1 series processors)
  • macOS 12.3 and above (Intel processor)

Enable VirtioFS in Docker Desktop:

  • Upgrade Docker Desktop to version 4.6, which can be downloaded here ;
  • Navigate to Preferences > Experimental Features
  • Select the "Enable VirtioFS accelerated directory sharing" option
  • Click "Apply and Restart";

VirtioFS is still in the experimental stage, so it is inevitable to encounter some problems during use. Users can report any problems found to the Docker Mac file system performance thread. There is currently a known issue where VirtioFS-enabled containers may fail with permission errors at runtime.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324788250&siteId=291194637