MIT 6.5840:Lecture 14 FaRM and Optimistic Concurrency Control
本篇逐行译注 MIT 6.5840 Spring 2026 Lecture 14,覆盖 FaRM、NVRAM、kernel bypass、RDMA、Optimistic Concurrency Control(OCC)、2PC 和 recovery。
MIT 6.5840:Lecture 14 FaRM and Optimistic Concurrency Control
TL;DR
- FaRM 的目标:在单 data center 中利用 NVRAM、kernel bypass 和 one-sided RDMA,把 distributed transactions 的 latency 压到几十 microseconds。
- OCC 的动机:transaction 在 execute phase 无锁读取,commit 时再检查 versions/lock bits;这样 read 可以直接使用 one-sided RDMA。
- FaRM 的 commit:LOCK 先在 primaries 上检查并设置 lock,随后 COMMIT-PRIMARY 使结果对外可见;备份通过 COMMIT-BACKUP 保存恢复所需信息。
- VALIDATE:对只读对象只重新读取 version/lock flag,不设置 lock,比 LOCK+COMMIT 更快。
- 边界:FaRM 依赖数据全部放入 RAM、特殊 NVRAM/RDMA hardware、低冲突 OCC 和单 data center;与 Spanner 的优化重点不同。
名词解释
| 名词 | 含义 | 本讲对应物 |
|---|---|---|
| FaRM | 利用 RDMA/NVRAM 的高性能 distributed transaction system | OCC + 2PC + primary/backup |
| NVRAM | Non-volatile RAM | 避免每次 commit 写 disk |
| RDMA | Remote Direct Memory Access | NIC 直接读写远端 RAM |
| Kernel bypass | application 直接与 NIC 交互 | 避免 system calls/kernel path |
| OCC | Optimistic Concurrency Control | 先读,commit 时 validate |
| LOCK | 对写对象检查 version 并设置 lock 的记录 | 写入 primary NVRAM log |
| VALIDATE | 重新检查只读对象的 version/lock flag | 不设置 lock 的快速检查 |
| COMMIT-PRIMARY | 让 primary 应用新值并解锁 | commit point 的证据 |
目录
| 章节 | 内容 |
|---|---|
| 版本与来源 | 固定 Lecture 14 源文件 |
| 原文逐行翻译 | 按 l-farm.txt 顺序译注 |
| 机制小结 | FaRM hardware path、OCC、commit 与 recovery |
| 本篇验收 | 源行、图示和术语边界记录 |
版本与来源
- 课程版本:MIT 6.5840 Spring 2026。
- Lecture 源文件:l-farm.txt,339 行,非空源行 295 行,SHA-256:
c204742cf9eb062f873f0b340a152b8a3c2495dc0f9a865fc2d9d77d191fd6fd。 - 配套论文:FaRM: Fast Remote Memory。
- 课程日程:MIT 6.5840 Spring 2026 Schedule。
- 翻译边界:英文源行按原顺序保留,随后给出中文译文;FaRM、NVRAM、RDMA、NIC、OCC、TC、oid、LOCK、VALIDATE、COMMIT-PRIMARY、COMMIT-BACKUP 和 Figure 编号原样保留。
- 图片结论:本 Lecture 源文件没有独立图片文件;kernel bypass/RDMA 图示、transaction timeline 和 Figure 引用按原位置保留。
原文逐行翻译
FaRM 的动机与整体 setup
6.5840 2026 Lecture 14: FaRM, Optimistic Concurrency Control
6.5840 2026 年 Lecture 14:FaRM、Optimistic Concurrency Control。
why are we reading about FaRM?
为什么要学习 FaRM?
another take on transactions+replication+sharding
这是对 transactions+replication+sharding 的另一种思路。
this is still an open research area!
这仍然是一个 open research area!
optimistic concurrency control
optimistic concurrency control。
exploiting huge performance potential of RDMA NICs
利用 RDMA NICs 巨大的 performance potential。
the overall setup
整体 setup。
all in one data center
全部位于一个 data center 中。
configuration manager, using ZooKeeper, chooses primaries/backups
configuration manager 使用 ZooKeeper 选择 primaries/backups。
sharded w/ primary/backup replication
使用 primary/backup replication 做 sharding。
P1 B1
P1 B1。
P2 B2
P2 B2。
...
...。
can recover as long as at least one replica of each shard
只要每个 shard 至少有一个 replica,就可以 recovery。
i.e. f+1 replicas tolerate f failures
也就是说,f+1 个 replicas 可以容忍 f 个 failures。
transaction clients (which they run in the servers)
transaction clients(它们运行在 servers 中)。
transaction code acts as two-phase-commit Transaction Coordinator (TC)
transaction code 充当 two-phase-commit Transaction Coordinator(TC)。
the goal:
目标:
millions of distributed transactions per second
每秒 millions of distributed transactions。
so the time budget is tens of microseconds
因此 time budget 是 tens of microseconds。
very challenging!
这是非常 challenging 的!
how do they get high performance?
他们如何获得 high performance?
sharding over many servers (90 in the evaluation)
在许多 servers 上 sharding(evaluation 中是 90 个)。
data must fit in total RAM (so no disk reads)
data 必须放入 total RAM(因此不需要 disk reads)。
non-volatile RAM (so no disk writes)
non-volatile RAM(因此不需要 disk writes)。
one-sided RDMA (fast cross-network access to RAM)
one-sided RDMA(快速跨 network 访问 RAM)。
fast user-level access to NIC
快速的 user-level NIC access。
transaction+replication protocol that exploits one-sided RDMA
利用 one-sided RDMA 的 transaction+replication protocol。
NVRAM
NVRAM (non-volatile RAM)
NVRAM(non-volatile RAM)。
FaRM writes go to RAM, not disk -- eliminates a huge bottleneck
FaRM writes 写入 RAM,而不是 disk——消除了一个巨大 bottleneck。
RAM write takes 200 ns, hard drive write takes 10 ms, SSD write 100 us
RAM write 需要 200 ns,hard drive write 需要 10 ms,SSD write 需要 100 us。
ns = nanosecond, ms = millisecond, us = microsecond
ns = nanosecond,ms = millisecond,us = microsecond。
but RAM loses content in power failure! not persistent by itself.
但 RAM 会在 power failure 时丢失 content!它本身不是 persistent 的。
why not just write to RAM of f+1 machines, to tolerate f failures?
为什么不直接写入 f+1 台 machines 的 RAM,以容忍 f 个 failures?
might be enough if failures were always independent
如果 failures 总是 independent,这可能就足够了。
but power failure is not independent -- may strike 100% of machines!
但 power failure 并不 independent——可能影响 100% 的 machines!
so:
因此:
batteries in every rack, can run machines for a few minutes
每个 rack 都有 batteries,可以让 machines 运行几分钟。
power h/w notifies s/w when main power fails
main power failure 时,power h/w 通知 s/w。
s/w halts all transaction processing
s/w halt 所有 transaction processing。
s/w writes FaRM's RAM to SSD; may take a few minutes
s/w 将 FaRM 的 RAM 写入 SSD;可能需要几分钟。
then machine shuts down
然后 machine shut down。
on re-start, FaRM reads saved memory image from SSD
re-start 时,FaRM 从 SSD 读取保存的 memory image。
"non-volatile RAM"
“non-volatile RAM”。
what if crash prevents s/w from writing SSD?
如果 crash 阻止 s/w 写入 SSD 怎么办?
e.g bug in FaRM or kernel, or cpu/memory/hardware error
例如 FaRM 或 kernel 中的 bug,或者 cpu/memory/hardware error。
FaRM copes with single-machine crashes with replication
FaRM 通过 replication 应对 single-machine crashes。
crashes (other than power failure) must be independent!
(power failure 之外的)crashes 必须是 independent 的!
summary:
总结:
NVRAM eliminates persistence write bottleneck
NVRAM 消除了 persistence write bottleneck。
leaving network and CPU as remaining bottlenecks
剩下的 bottlenecks 是 network 和 CPU。
Network、kernel bypass 与 RDMA
why is the network often a performance bottleneck?
为什么 network 经常成为 performance bottleneck?
FaRM assumes single data-center, so low speed-of-light delay
FaRM 假设 single data-center,因此 speed-of-light delay 很低。
but CPU cost of network data handling is often large!
但 network data handling 的 CPU cost 经常很大!
the usual setup for RPC over TCP over LAN:
RPC over TCP over LAN 的 usual setup:
app app
app app。
--- ---
--- ---。
socket buffers buffers
socket buffers buffers。
TCP TCP
TCP TCP。
NIC driver driver
NIC driver driver。
NIC -------------------- NIC
NIC -------------------- NIC。
lots of expensive CPU operations:
许多 expensive CPU operations:
system calls
system calls。
copy messages
copy messages。
interrupts
interrupts。
context switches
context switches。
slow:
慢:
hard to build RPC than can deliver more than a few 100,000 / second
很难构建每秒交付超过 few 100,000 次的 RPC。
wire b/w (e.g. 10 gigabits/second) is rarely the limit for short RPC
对于 short RPC,wire b/w(例如 10 gigabits/second)很少是 limit。
per-packet CPU costs traditionally limit performance for small messages
对于 small messages,per-packet CPU costs 传统上会限制 performance。
FaRM uses two networking ideas:
FaRM 使用两个 networking ideas:
Kernel bypass
Kernel bypass。
RDMA
RDMA。
Kernel bypass
Kernel bypass。
[diagram: FaRM user program, CPU cores, DMA queues, NIC]
[diagram:FaRM user program、CPU cores、DMA queues、NIC]。
application directly interacts with NIC -- no system calls, no kernel
application 直接与 NIC 交互——没有 system calls,也不经过 kernel。
NIC DMAs into/out of user RAM
NIC 通过 DMA 写入/读出 user RAM。
FaRM s/w polls DMA areas to check for incoming messages
FaRM s/w poll DMA areas,以检查 incoming messages。
NIC polls DMA areas to check for outgoing messages
NIC poll DMA areas,以检查 outgoing messages。
RDMA (remote direct memory access)
RDMA(remote direct memory access)。
[src host, NIC, switch, NIC, target memory, target CPU]
[src host、NIC、switch、NIC、target memory、target CPU]。
remote NIC directly reads/writes memory
remote NIC 直接 read/write memory。
Sender provides memory address
Sender 提供 memory address。
Remote CPU is not involved!
Remote CPU 不参与!
This is "one-sided RDMA"
这就是“one-sided RDMA”。
Reads an entire cache line, atomically
它 atomically 读取完整的 cache line。
RDMA NICs use reliable protocol, with ACKs
RDMA NICs 使用带 ACKs 的 reliable protocol。
one server's throughput: 10+ million/second (Figure 2)
一个 server 的 throughput:10+ million/second(Figure 2)。
latency: 5 microseconds (from their NSDI 2014 paper)
latency:5 microseconds(来自其 NSDI 2014 paper)。
Performance would be amazing if clients could directly access
如果 clients 可以直接访问,performance 将非常 amazing,
DB records on servers via one-sided RDMA!
也就是通过 one-sided RDMA 访问 servers 上的 DB records!
OCC 与 FaRM API
How to combine one-sided RDMA with replication and transactions?
如何把 one-sided RDMA 与 replication、transactions 结合?
The protocols we've seen so far require active server participation.
我们目前看到的 protocols 都需要 active server participation。
e.g. to check and set locks,
例如 check 和 set locks,
to check lease,
check lease,
to indicate when safely persisted.
指示何时 safely persisted。
Not immediately compatible with one-sided RDMA.
它们不能立即与 one-sided RDMA 兼容。
two classes of concurrency control for transactions:
transactions 有两类 concurrency control:
pessimistic (two-phase locking):
pessimistic(two-phase locking):
wait for lock on first use of object; hold until commit/abort
第一次使用 object 时等待 lock;一直持有到 commit/abort。
conflicts cause delays
conflicts 会导致 delays。
optimistic:
optimistic:
read objects without locking
不加 locking 地读取 objects。
don't install writes until commit
直到 commit 才 install writes。
commit "validates" to see if other xactions conflicted
commit 时“validates”,检查其他 xactions 是否发生 conflict。
valid: commit the writes
valid:commit writes。
invalid: abort
invalid:abort。
called Optimistic Concurrency Control (OCC)
称为 Optimistic Concurrency Control(OCC)。
FaRM uses OCC
FaRM 使用 OCC。
the reason:
原因:
OCC lets FaRM read using one-sided RDMA reads
OCC 允许 FaRM 使用 one-sided RDMA reads。
so server needn't actively participate in reads
因此 server 不需要 active 地参与 reads。
how does FaRM's OCC validate? we'll look at Figure 4 in a minute.
FaRM 的 OCC 如何 validate?我们马上看 Figure 4。
FaRM transaction API (simplified):
FaRM transaction API(简化版):
txCreate()
txCreate()。
o = txRead(oid) -- RDMA
o = txRead(oid) -- RDMA。
o.f += 1
o.f += 1。
txWrite(oid, o) -- purely local
txWrite(oid, o) -- purely local。
ok = txCommit() -- Figure 4
ok = txCommit() -- Figure 4。
what's an oid?
oid 是什么?
<region #, address>
<region #, address>。
region # indexes a mapping to [ primary, backup1, ... ]
region # index 到一个 [ primary, backup1, ... ] mapping。
target RDMA NIC uses address directly to read RAM
target RDMA NIC 直接使用 address 读取 RAM。
Server memory layout 与 Figure 4
server memory layout
server memory layout。
regions, each an array of objects
regions,每个 region 是一个 objects array。
object layout
object layout。
header with version #, and lock flag in high bit of version #
header 中有 version #,version # 的 high bit 中有 lock flag。
for each other server
对于每个 other server:
incoming log
incoming log。
incoming message queue
incoming message queue。
(senders write via RDMA, local FaRM reads via polling)
(senders 通过 RDMA 写入,local FaRM 通过 polling 读取。)
all this in non-volatile RAM (i.e. written to SSD on power failure)
所有这些都在 non-volatile RAM 中(即 power failure 时写入 SSD)。
Figure 4: transaction execution / commit protocol
Figure 4:transaction execution / commit protocol。
let's consider steps in Figure 4 one by one
我们逐一考虑 Figure 4 中的步骤。
focus on concurrency control (not fault tolerance)
重点是 concurrency control(不是 fault tolerance)。
Execute phase
Execute phase
Execute phase。
TC (the client) reads the objects it needs from servers
TC(client)从 servers 读取所需 objects。
including records that it will write
包括它将要 write 的 records。
using one-sided RDMA reads
使用 one-sided RDMA reads。
without locking
不使用 locking。
this is the optimism in Optimistic Concurrency Control
这就是 Optimistic Concurrency Control 中的 optimism。
TC remembers the version numbers
TC 记住 version numbers。
TC buffers writes locally
TC 在本地 buffers writes。
now TC commits; two big goals:
现在 TC commit;有两个大目标:
atomic distributed commit -- all writes or none
atomic distributed commit——所有 writes 生效,或者一个都不生效。
serializability -- as if entirely before or after every other transaction
serializability——仿佛整个 transaction 在每个其他 transaction 之前或之后执行。
LOCK
LOCK (first message in commit protocol)
LOCK(commit protocol 中的第一条 message)。
TC sends to primary of each written object
TC 将它发送给每个 written object 的 primary。
TC uses RDMA to append to its log at each primary
TC 使用 RDMA 向每个 primary 的 log append。
LOCK record contains oid, version # xaction read, new value
LOCK record 包含 oid、xaction read 的 version #、new value。
LOCK is now logged in primary's NVRAM
LOCK 现在已经 log 到 primary 的 NVRAM 中。
will survive a power failure
它能够在 power failure 后存活。
LOCK message is both a write-ahead log entry,
LOCK message 同时是 write-ahead log entry,
and an RPC request to the primary
以及发给 primary 的 RPC request。
what does primary do on receipt of LOCK?
primary 收到 LOCK 后做什么?
FaRM s/w polls incoming logs in RAM, sees our LOCK
FaRM s/w poll RAM 中的 incoming logs,看到我们的 LOCK。
if object locked, or version != what xaction read,
如果 object 已 locked,或者 version != xaction read 的 version,
send "no" reply to TC
就向 TC 发送“no” reply。
otherwise set the object's lock flag and reply "yes"
否则设置 object 的 lock flag,并回复“yes”。
but don't yet modify the data!
但暂时不要 modify data!
lock check, version check, and lock set are atomic
lock check、version check 和 lock set 是 atomic 的。
using atomic compare-and-swap instruction
使用 atomic compare-and-swap instruction。
"locked" flag is high-order bit in object's version number
“locked” flag 是 object version number 的 high-order bit。
in case other CPU also processing a LOCK, or a client is reading w/ RDMA
这样可以处理其他 CPU 也在 processing LOCK,或 client 正在通过 RDMA read 的情况。
TC waits for all LOCK reply messages
TC 等待所有 LOCK reply messages。
if any "no", abort
如果任意一个是“no”,就 abort。
append ABORT to primaries' logs so they can release locks
向 primaries 的 logs append ABORT,使它们能够 release locks。
returns "no" from txCommit()
从 txCommit() 返回“no”。
let's ignore VALIDATE and COMMIT BACKUP for now
现在先忽略 VALIDATE 和 COMMIT BACKUP。
at this point primaries need to know TC's decision
此时 primaries 需要知道 TC 的 decision。
TC appends COMMIT-PRIMARY to primaries' logs
TC 向 primaries 的 logs append COMMIT-PRIMARY。
TC only waits for RDMA hardware acknowledgement (ack)
TC 只等待 RDMA hardware acknowledgement(ack)。
does not wait for primary to process log entry
它不等待 primary process log entry。
hardware ack means safe in primary's NVRAM
hardware ack 意味着它已经 safe 地位于 primary 的 NVRAM 中。
TC returns "yes" from txCommit()
TC 从 txCommit() 返回“yes”。
when primary processes COMMIT-PRIMARY in its log:
当 primary 在其 log 中 process COMMIT-PRIMARY 时:
copy new value to object's memory
把 new value copy 到 object 的 memory。
increment object's version #
increment object 的 version #。
clear object's lock flag
clear object 的 lock flag。
the commit point is when the first COMMIT-PRIMARY is written
commit point 是第一个 COMMIT-PRIMARY 被写入的时刻。
since at that point the transactions results can be revealed
因为从这个时刻起 transaction results 可以被 reveal。
OCC 的 serializability
example:
例子:
T1 and T2 both want to increment x
T1 和 T2 都想 increment x。
x = x + 1
x = x + 1。
what results does serializability allow?
serializability 允许哪些 results?
i.e. what outcomes are possible if run one at a time?
也就是说,如果 one at a time 运行,可能有哪些 outcomes?
x = 2, both clients told "success"
x = 2,告诉两个 clients “success”。
x = 1, one client told "success", other "aborted"
x = 1,告诉一个 client “success”,另一个“aborted”。
x = 0, both clients told "aborted"
x = 0,告诉两个 clients “aborted”。
what if T1 and T2 are exactly in step?
如果 T1 和 T2 恰好同步呢?
T1: Rx0 Lx Cx
T1: Rx0 Lx Cx。
T2: Rx0 Lx Cx
T2: Rx0 Lx Cx。
what will happen?
会发生什么?
or
或者:
T1: Rx0 Lx Cx
T1: Rx0 Lx Cx。
T2: Rx0 Lx Cx
T2: Rx0 Lx Cx。
or
或者:
T1: Rx0 Lx Cx
T1: Rx0 Lx Cx。
T2: Rx0 Lx Cx
T2: Rx0 Lx Cx。
intuition for why FaRM's OCC provides serializability:
FaRM OCC 提供 serializability 的直觉:
i.e. checks "was execution same as one at a time?"
也就是检查“execution 是否与 one at a time 相同?”
if there was no conflicting transaction:
如果不存在 conflicting transaction:
the versions won't have changed
versions 不会发生变化。
if there was a conflicting transaction:
如果存在 conflicting transaction:
one or the other will see a lock or changed version #
两者之一会看到 lock 或 changed version #。
VALIDATE
what about VALIDATE in Figure 4?
Figure 4 中的 VALIDATE 呢?
it is an optimization for objects that are just read by a transaction
它是针对只被 transaction read 的 objects 的 optimization。
VALIDATE = one-sided RDMA read to re-fetch object's version # and lock flag
VALIDATE = 使用 one-sided RDMA read 重新 fetch object 的 version # 和 lock flag。
if lock set, or version # changed since read, TC aborts
如果 lock set,或者 version # 自 read 后发生变化,TC abort。
does not set the lock, thus faster than LOCK+COMMIT
它不 set lock,因此比 LOCK+COMMIT 更快。
VALIDATE example:
VALIDATE 示例:
x and y initially zero
x 和 y 初始为 zero。
T1:
T1:。
if x == 0:
if x == 0:。
y = 1
y = 1。
T2:
T2:。
if y == 0:
if y == 0:。
x = 1
x = 1。
(this is a classic test example for transactions)
(这是 transactions 的 classic test example。)
T1,T2 yields y=1,x=0
T1、T2 产生 y=1,x=0。
T2,T1 yields x=1,y=0
T2、T1 产生 x=1,y=0。
aborts could leave x=0,y=0
aborts 可能留下 x=0,y=0。
but serializability forbids x=1,y=1
但 serializability 禁止 x=1,y=1。
suppose simultaneous:
假设 simultaneous:
T1: Rx Ly Vx Cy
T1: Rx Ly Vx Cy。
T2: Ry Lx Vy Cx
T2: Ry Lx Vy Cx。
what will happen?
会发生什么?
the LOCKs will both succeed!
两个 LOCKs 都会成功!
the VALIDATEs will both fail, since lock bits are both set
两个 VALIDATEs 都会失败,因为两个 lock bits 都已 set。
so both will abort -- which is OK
所以两者都会 abort——这是 OK 的。
how about:
那么:
T1: Rx Ly Vx Cy
T1: Rx Ly Vx Cy。
T2: Ry Lx Vy Cx
T2: Ry Lx Vy Cx。
T1 commits
T1 commits。
T2 aborts since T2's Vy sees T1's lock or higher version
T2 aborts,因为 T2 的 Vy 看到 T1 的 lock 或 higher version。
but we can't have both V's before the other L's
但不可能让 both V 都发生在另一个 L 之前。
so VALIDATE seems correct in this example
所以在这个例子中 VALIDATE 看起来是 correct 的。
and fast: one-sided VALIDATE read rather than LOCK+COMMIT writes
而且很 fast:使用 one-sided VALIDATE read,而不是 LOCK+COMMIT writes。
a purely read-only FaRM transaction uses only one-sided RDMA reads
purely read-only 的 FaRM transaction 只使用 one-sided RDMA reads。
no writes, no log records, no locking
没有 writes、log records 或 locking。
very fast!
非常 fast!
Fault tolerance 与 recovery
what about fault tolerance?
fault tolerance 呢?
suppose some computers crash and don't reboot
假设一些 computers crash 且不 reboot。
most interesting if TC and some primaries crash
最有趣的情况是 TC 和一些 primaries crash。
but we assume one backup from each shard survives
但我们假设每个 shard 都有一个 backup survive。
the critical issue:
关键问题:
if a transaction was interrupted by a failure,
如果 transaction 被 failure 打断,
and a client could have been told a transaction committed,
且 client 可能已经被告知 transaction committed,
or a committed value could have been read by another xaction,
或者 committed value 可能已经被另一个 xaction read,
then the transaction must be preserved and completed during recovery.
那么该 transaction 必须在 recovery 期间被 preserved 并 completed。
look at Figure 4.
看 Figure 4。
a committed write might be revealed as soon the
committed write 可能在
first COMMIT-PRIMARY is sent (since primary writes and unlocks).
发送第一个 COMMIT-PRIMARY 后立即被 reveal(因为 primary writes 并 unlocks)。
so by then, all of the transaction's writes must be on all
因此到那时,transaction 的所有 writes 必须位于所有
f+1 replicas of all relevant shards.
相关 shards 的 f+1 replicas 上。
the good news: LOCK and COMMIT-BACKUP achieve this.
好消息是:LOCK 和 COMMIT-BACKUP 实现了这一点。
LOCK tells all primaries the new value(s).
LOCK 告诉所有 primaries new value(s)。
COMMIT-BACKUP tells all backups the new value(s).
COMMIT-BACKUP 告诉所有 backups new value(s)。
TC doesn't send COMMIT-PRIMARY until all LOCKs and COMMIT-BACKUPS complete.
只有所有 LOCKs 和 COMMIT-BACKUPS complete 后,TC 才发送 COMMIT-PRIMARY。
backups may not have processed COMMIT-BACKUPs, but in NVRAM logs.
backups 可能还没有 processed COMMIT-BACKUPs,但它们已经在 NVRAM logs 中。
similarly, TC doesn't return to client until at least one
同样,TC 不会 return 给 client,直到至少一个
COMMIT-PRIMARY is safe in primary log.
COMMIT-PRIMARY 在 primary log 中 safe。
without the COMMIT-PRIMARY, the risky case is:
没有 COMMIT-PRIMARY 时,risk case 是:
TC replies "yes" to app after COMMIT-BACKUPS (before COMMIT-PRIMARY).
TC 在 COMMIT-BACKUPS 之后(COMMIT-PRIMARY 之前)回复 app “yes”。
TC and all backups then fail.
随后 TC 和所有 backups failure。
now the only evidence left is the LOCK records.
此时唯一剩下的 evidence 是 LOCK records。
but even a complete set of LOCK records doesn't tell us if TC committed
但即使有完整的 LOCK records,也不能告诉我们 TC 是否 committed。
maybe TC aborted due to failed VALIDATE!
因为 TC 可能由于 VALIDATE failure 而 aborted!
writing the COMMIT-PRIMARY handles the risk, because the TC's
写入 COMMIT-PRIMARY 可以处理该 risk,因为 TC 的
decision will survive f failures of any shard.
decision 能够在任意 shard 的 f 个 failures 后 survive。
since there's one shard with a full set of COMMIT-BACKUP and COMMIT-PRIMARY.
因为至少有一个 shard 拥有完整的 COMMIT-BACKUP 和 COMMIT-PRIMARY。
any of which is evidence that the primary decided to commit.
其中任意一个都是 primary decided to commit 的 evidence。
FaRM 与 Spanner
FaRM is very impressive; does it fall short of perfection?
FaRM 非常 impressive;它是否仍然不完美?
- works best if few conflicts, due to OCC.
- 由于 OCC,conflicts 少时 work best。
- data must fit in total RAM.
- data 必须 fit in total RAM。
- replication only within a datacenter (no geographic distribution).
- replication 只在一个 datacenter 内(没有 geographic distribution)。
- the data model is low-level; would need e.g. SQL library.
- data model 是 low-level 的;例如需要 SQL library。
- requires somewhat unusual RDMA and NVRAM hardware.
- 需要 somewhat unusual 的 RDMA 和 NVRAM hardware。
how does FaRM differ from Spanner?
FaRM 与 Spanner 有何不同?
both shard, replicate, and use two-phase commit (2pc) for transactions
两者都 sharding、replicate,并为 transactions 使用 two-phase commit(2pc)。
Spanner:
Spanner:
focuses on coping with network delay due to geographic replication
重点是应对 geographic replication 导致的 network delay。
Paxos tolerates delay
Paxos 能容忍 delay。
TrueTime lets them read from local replicas
TrueTime 允许它们从 local replicas 读取。
performance: r/w xaction takes 10 to 100 ms (Tables 3 and 6)
performance:r/w xaction 需要 10 到 100 ms(Tables 3 和 6)。
FaRM
FaRM:
focuses on reducing CPU costs
重点是 reducing CPU costs。
RDMA, direct NIC access, NVRAM to avoid disk writes
使用 RDMA、direct NIC access、NVRAM 来避免 disk writes。
RDMA leads them to Optimistic Concurrency Control (OCC)
RDMA 促使它们采用 Optimistic Concurrency Control(OCC)。
performance: 58 microseconds for simple transactions (6.3, Figure 7)
performance:simple transactions 需要 58 microseconds(6.3、Figure 7)。
i.e. 100 times faster than Spanner
也就是比 Spanner 快 100 倍。
summary
总结。
super high speed distributed transactions
super high speed distributed transactions。
hardware is exotic (NVRAM and RDMA) but may be common soon
hardware 是 exotic 的(NVRAM 和 RDMA),但可能很快变得 common。
use of OCC for speed and to allow fast one-sided RDMA reads
使用 OCC 获得 speed,并允许 fast one-sided RDMA reads。
机制小结
1. FaRM 的 hardware path
FaRM 把 data 放在 RAM,把 persistence 交给 NVRAM 的 power-failure 保存流程;kernel bypass 让 application 直接操作 NIC 和 DMA queues;one-sided RDMA 让 remote NIC 直接读写 target memory,不需要 remote CPU 参与。这些机制把 disk、kernel 和 RPC per-packet CPU costs 从关键路径上移开。
2. OCC 的 execute/commit 分离
execute phase 只通过 RDMA read objects 并记录 version numbers,writes 留在 TC 本地。commit 时,写对象先通过 LOCK 原子地检查 version、设置 lock;只读对象用 VALIDATE 重新检查 version/lock flag。若检查成功,再用 COMMIT-PRIMARY 让写入生效。
3. Commit point 与 recovery
第一个 COMMIT-PRIMARY 写入 primary log 后,transaction result 可能被 reveal,因此所有相关 shards 的 replicas 必须已有恢复所需的 LOCK/COMMIT-BACKUP 信息。TC 等待 RDMA hardware ack,而不是等待 primary 处理 log entry,从而在保证 NVRAM safety 的同时降低 latency。
4. FaRM 与 Spanner 的优化方向
Spanner 面向 geographic replication,使用 Paxos、TrueTime 和 local replica read 来应对 WAN delay;FaRM 假设 single data center,重点降低 CPU、disk 和 network handling cost,依靠 RDMA/NVRAM/OCC 达到更低 latency,但牺牲了 geographic distribution、通用 data model 和 hardware 普及性。
本篇验收
- [x] 官方
l-farm.txt已固定:339 行、295 个非空源行,SHA-256 与来源记录一致。 - [x] 源文本的非空行按原顺序逐行保留,中文译文紧随对应英文源行。
- [x] FaRM setup、NVRAM、kernel bypass、RDMA、OCC、LOCK、VALIDATE、COMMIT-PRIMARY、COMMIT-BACKUP、recovery 和 Spanner 对比全部覆盖。
- [x] 网络/RDMA diagram、transaction timeline、Figure 引用和 ASCII protocol examples 均按原位置保留;源文件没有独立图片。
- [x] FaRM、NVRAM、RDMA、NIC、OCC、TC、oid、LOCK、VALIDATE 和 commit record 名称保留原样。
- [ ] Lecture 14 的中文译文仍建议进行一次人工术语审校;自动审计只验证源文覆盖与顺序,不证明翻译语义正确。
评论 (0)