TLDR: Copy-On-Write - When to Use It, When to Avoid It
Date: 2020-05-03 Source: https://arpitbhayani.me/blogs/copy-on-write
Overview
Explore Copy-on-Write (CoW) - Boost performance, manage resources, and enable versioning. Learn how it works with examples and trade-offs. Copy-On-Write, abbreviately referred to as CoW suggests deferring the copy process until the first modification.
Key Points
- Copy-On-Write, abbreviately referred to as CoW suggests deferring the copy process until the first modification.
- Perceived performance gain: By having a CoW, the process need not wait for the deep copy to happen, instead, it could directly proceed by just doing a copy-by-reference, where the resource is shared between the two, which is much faster than a deep copy and thus gaining a performance boost.
- Better resource management: CoW gives us an optimistic way to manage memory.
- Updating without locks: Locks are required when we have in-place updates.