summaryrefslogtreecommitdiff
path: root/libitm/doc/nesting-flat-vs-closed.rst
blob: 8b157baed981cb3b968ad3a27f19c6af6c0eb048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
  Copyright 1988-2022 Free Software Foundation, Inc.
  This is part of the GCC manual.
  For copying conditions, see the copyright.rst file.

Nesting: flat vs. closed
************************

We support two different kinds of nesting of transactions. In the case of
*flat nesting*, the nesting structure is flattened and all nested
transactions are subsumed by the enclosing transaction. In contrast,
with *closed nesting*, nested transactions that have not yet committed
can be rolled back separately from the enclosing transactions; when they
commit, they are subsumed by the enclosing transaction, and their effects
will be finally committed when the outermost transaction commits.
*Open nesting* (where nested transactions can commit independently of the
enclosing transactions) are not supported.

Flat nesting is the default nesting mode, but closed nesting is supported and
used when transactions contain user-controlled aborts
(``__transaction_cancel`` statements). We assume that user-controlled
aborts are rare in typical code and used mostly in exceptional situations.
Thus, it makes more sense to use flat nesting by default to avoid the
performance overhead of the additional checkpoints required for closed
nesting. User-controlled aborts will correctly abort the innermost enclosing
transaction, whereas the whole (i.e., outermost) transaction will be restarted
otherwise (e.g., when a transaction encounters data conflicts during
optimistic execution).