Skip to content

Commit ff0cfda

Browse files
committed
update gc
1 parent e852c3f commit ff0cfda

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

gc.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,19 @@ func gcStart(mode gcMode, trigger gcTrigger) {
308308
systemstack(func() {
309309
finishsweep_m()
310310
})
311-
// clearpools before we start the GC. If we wait they memory will not be
312-
// reclaimed until the next GC cycle.
311+
312+
// 清除全局的 :
313+
// 1. sudogcache(sudog 数据结构的链表)
314+
// 2. deferpool(defer struct 的链表的数组)
315+
// 3. sync.Pool
313316
clearpools()
314317

315318
work.cycles++
316-
if mode == gcBackgroundMode { // Do as much work concurrently as possible
319+
if mode == gcBackgroundMode { // 尽量多地提高并发度
317320
gcController.startCycle()
318321
work.heapGoal = memstats.next_gc
319322

320-
// Enter concurrent mark phase and enable
321-
// write barriers.
323+
// 进入并发标记阶段,并让 write barriers 开始生效
322324
//
323325
// Because the world is stopped, all Ps will
324326
// observe that write barriers are enabled by

memory_barrier.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# memory barrier
2+
3+
memory barrier 也称为 memory fence。
4+
5+
参考资料:
6+
7+
https://homes.cs.washington.edu/~bornholt/post/memory-models.html
8+
9+
https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html

0 commit comments

Comments
 (0)