Abstract
Docker, as a mainstream container solution, adopts the Copy-on-Write (CoW) mechanism in its storage drivers to allow containers to share the same image layers. However, when a container modifies an image file, a duplicate is created in the upper read-write layer, introducing significant runtime overhead—especially for large files. This paper proposes Dynamic Prefetching Strategy Optimization (DPSO), which optimizes the CoW mechanism by predicting and pre-copying files during the container's startup idle time. Experimental results demonstrate that DPSO achieves an average prefetch accuracy of over 78% and effectively eliminates runtime CoW overhead.
Introduction: The "Copy-on-Write" Tax
Docker images are structured in layers to optimize storage efficiency. Multiple containers can share the same read-only image layers, but any modification to a file requires the storage driver (e.g., OverlayFS) to perform a "copy-up" operation. This operation duplicates the file from the read-only layer to the container's specific read-write layer.
While negligible for small configuration files, this "copy-up" tax becomes a performance bottleneck for large data files or high-volume file modifications. As shown in the performance analysis, the access overhead increases exponentially with file size, reaching nearly 100 seconds ($10^8 \mu s$) for a 4 GB file.
Methodology: Dynamic Prefetching Strategy Optimization (DPSO)
The proposed DPSO system aims to hide this latency by exploiting the "idle gap" between container startup and application execution. The system consists of four primary modules:
- Metadata Collection: Hooks into the OverlayFS driver to record file copy-up events during runtime.
- Storage & Processing: Stores metadata (File ID, frequency, timestamps) in a host-side database.
- Probability Model: Ranks files based on their likelihood of being modified, leveraging the deterministic nature of container workloads.
- Pre-operation Module: A client-server architecture where the container client fetches high-probability file lists and triggers "pre-copy" operations during idle time.
Key Insights
- Exploiting Determinism: Container behavior is often predictable across multiple instances of the same image. DPSO leverages this to predict future file access patterns based on historical usage.
- Latency Hiding: By shifting heavy I/O operations into the initialization window, the system ensures that the application experiences near-zero file system lag once it starts.
- Efficiency Threshold: To minimize metadata overhead, the authors implemented a 256 KB filter, focusing prefetching efforts on files where the performance gains are most significant compared to the tracking cost.
Results and Performance
Evaluation using synthetic Ubuntu-based workloads showed that DPSO can reduce runtime overhead for a 4 GB file from approximately 70 seconds to just 0.067 ms, provided sufficient idle time is available to complete the pre-copy. Across complex scenarios, the system maintained a high prediction accuracy, averaging 78.6%. The system overhead for metadata management remained minimal, costing roughly 10 ms per 100 files—a negligible price for eliminating seconds or minutes of runtime lag.
Conclusion
DPSO effectively addresses the performance limitations of Docker's CoW mechanism. By intelligently prefetching files during startup, it eliminates runtime delays that would otherwise freeze applications. Future work will explore more advanced machine learning models to improve prediction accuracy for non-deterministic workloads and integrate the system as a native Docker plugin.
Summary updated