Skip to content

Commit f23c1e3

Browse files
committed
Formatting adjustment based on review.
1 parent b313c1e commit f23c1e3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

InternalDocs/qsbr.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ for threads to report this state.
2626
While CPython's memory management is dominated by reference counting and a
2727
tracing garbage collector, these mechanisms are not suitable for all data
2828
structures. For example, the backing array of a list object is not individually
29-
reference-counted but may have a shorter lifetime than the PyListObject that
29+
reference-counted but may have a shorter lifetime than the `PyListObject` that
3030
contains it. We could delay reclamation until the next GC run, but we want
3131
reclamation to be prompt and to run the GC less frequently in the free-threaded
3232
build, as it requires pausing all threads.
@@ -39,7 +39,7 @@ mechanism to determine when it is safe to free the list's old backing array.
3939

4040
Specific use cases for QSBR include:
4141

42-
* Dictionary keys (PyDictKeysObject) and list arrays (`_PyListArray`): When a
42+
* Dictionary keys (`PyDictKeysObject`) and list arrays (`_PyListArray`): When a
4343
dictionary or list that may be shared between threads is resized, we use QSBR
4444
to delay freeing the old keys or array until it's safe. For dicts and lists
4545
that are not shared, their storage can be freed immediately upon resize.
@@ -58,12 +58,13 @@ page or return its memory to the OS.
5858

5959
### Core Implementation
6060

61-
The proposal to add QSBR to Python is contained in Github issue 115103 [^1].
61+
The proposal to add QSBR to Python is contained in [Github issue 115103]
62+
(https://github.com/python/cpython/issues/115103).
6263
Many details of that proposal have been copied here, so they can be kept
6364
up-to-date with the actual implementation.
6465

6566
Python's QSBR implementation is based on FreeBSD's "Global Unbounded
66-
Sequences." [2, 3, 4]. It relies on a few key counters:
67+
Sequences." [^1, ^2, ^3]. It relies on a few key counters:
6768

6869
* Global Write Sequence (`wr_seq`): A per-interpreter counter, `wr_seq`, is started
6970
at 1 and incremented by 2 each time it is advanced. This ensures its value is
@@ -92,7 +93,7 @@ Periodically, a polling mechanism processes this deferred-free list:
9293
stored as the global `rd_seq`.
9394

9495
2. For each item on the deferred-free list, if its qsbr_goal is less than or
95-
equal to the new `rd_seq`, its memory is freed, and it is removed from the
96+
equal to the new `rd_seq`, its memory is freed, and it is removed from the:
9697
list. Otherwise, it remains on the list for a future attempt.
9798

9899

@@ -123,7 +124,6 @@ multi-threaded benchmarks reveal performance issues.
123124

124125
## References
125126

126-
[^1]: https://github.com/python/cpython/issues/115103
127-
2. https://youtu.be/ZXUIFj4nRjk?t=694
128-
3. https://people.kernel.org/joelfernandes/gus-vs-rcu
129-
4. http://bxr.su/FreeBSD/sys/kern/subr_smr.c#44
127+
[^1]: https://youtu.be/ZXUIFj4nRjk?t=694
128+
[^2]: https://people.kernel.org/joelfernandes/gus-vs-rcu
129+
[^3]: http://bxr.su/FreeBSD/sys/kern/subr_smr.c#44

0 commit comments

Comments
 (0)