optimization - 什么是写时复制?

标签 optimization design-patterns data-structures copy-on-write proxy-pattern

我想知道写时复制是什么以及它的用途。 Sun JDK 教程中多次提到该术语。

最佳答案

我本来想写下我自己的解释,但是this Wikipedia article总结得差不多了。

这是基本概念:

Copy-on-write (sometimes referred to as "COW") is an optimization strategy used in computer programming. The fundamental idea is that if multiple callers ask for resources which are initially indistinguishable, you can give them pointers to the same resource. This function can be maintained until a caller tries to modify its "copy" of the resource, at which point a true private copy is created to prevent the changes becoming visible to everyone else. All of this happens transparently to the callers. The primary advantage is that if a caller never makes any modifications, no private copy need ever be created.

这里还有一个常见的 COW 应用:

The COW concept is also used in maintenance of instant snapshot on database servers like Microsoft SQL Server 2005. Instant snapshots preserve a static view of a database by storing a pre-modification copy of data when underlaying data are updated. Instant snapshots are used for testing uses or moment-dependent reports and should not be used to replace backups.

关于optimization - 什么是写时复制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/628938/

相关文章:

algorithm - 二叉搜索树与排序双向链表

c - 哈希数组链表冲突解决错误

python - scipy.optimize.minimize,使用整数规划的旅行推销员

java - 我们需要 Builder 模式中的 .build() 方法吗?

c# - catch 语句中的附加 try 语句 - 代码味道?

C++:应用复合模式

c - 特殊情况的快速整数对数

optimization - CP-Sat 中 NumConflicts 的确切含义是什么?

python-3.x - Euler 12 需要优化

c++ - C++ map of maps 上的细粒度锁