X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/runtime
opt
/
golang
/
1.17.2
/
src
/
runtime
/
π
..
π
HACKING.md
(13.07 KB)
π
Makefile
(178 B)
π
abi_test.go
(2.88 KB)
π
alg.go
(9.45 KB)
π
asm.s
(715 B)
π
asm_386.s
(40.27 KB)
π
asm_amd64.s
(56.93 KB)
π
asm_arm.s
(30.23 KB)
π
asm_arm64.s
(33 KB)
π
asm_mips64x.s
(22.43 KB)
π
asm_mipsx.s
(24.39 KB)
π
asm_ppc64x.h
(1023 B)
π
asm_ppc64x.s
(29.16 KB)
π
asm_riscv64.s
(22.43 KB)
π
asm_s390x.s
(26.04 KB)
π
asm_wasm.s
(9.8 KB)
π
atomic_arm64.s
(259 B)
π
atomic_mips64x.s
(326 B)
π
atomic_mipsx.s
(284 B)
π
atomic_pointer.go
(2.62 KB)
π
atomic_ppc64x.s
(461 B)
π
atomic_riscv64.s
(275 B)
π
auxv_none.go
(360 B)
π
callers_test.go
(7.72 KB)
π
cgo
π
cgo.go
(2.01 KB)
π
cgo_mmap.go
(2.42 KB)
π
cgo_ppc64x.go
(439 B)
π
cgo_sigaction.go
(3.17 KB)
π
cgocall.go
(18.88 KB)
π
cgocallback.go
(317 B)
π
cgocheck.go
(6.83 KB)
π
chan.go
(23.54 KB)
π
chan_test.go
(23.01 KB)
π
chanbarrier_test.go
(1.4 KB)
π
checkptr.go
(3.29 KB)
π
checkptr_test.go
(1.62 KB)
π
closure_test.go
(937 B)
π
compiler.go
(413 B)
π
complex.go
(1.59 KB)
π
complex_test.go
(1.05 KB)
π
conv_wasm_test.go
(2.96 KB)
π
cpuflags.go
(800 B)
π
cpuflags_amd64.go
(533 B)
π
cpuflags_arm64.go
(334 B)
π
cpuprof.go
(6.92 KB)
π
cputicks.go
(497 B)
π
crash_cgo_test.go
(16.17 KB)
π
crash_nonunix_test.go
(429 B)
π
crash_test.go
(20.96 KB)
π
crash_unix_test.go
(8.52 KB)
π
debug
π
debug.go
(1.63 KB)
π
debug_test.go
(6.82 KB)
π
debugcall.go
(6.21 KB)
π
debuglog.go
(17.49 KB)
π
debuglog_off.go
(377 B)
π
debuglog_on.go
(1.11 KB)
π
debuglog_test.go
(4.56 KB)
π
defer_test.go
(10.32 KB)
π
defs1_linux.go
(862 B)
π
defs1_netbsd_386.go
(2.84 KB)
π
defs1_netbsd_amd64.go
(3.07 KB)
π
defs1_netbsd_arm.go
(2.96 KB)
π
defs1_netbsd_arm64.go
(3.18 KB)
π
defs1_solaris_amd64.go
(4.02 KB)
π
defs2_linux.go
(3.52 KB)
π
defs3_linux.go
(1.11 KB)
π
defs_aix.go
(4.18 KB)
π
defs_aix_ppc64.go
(3.63 KB)
π
defs_arm_linux.go
(2.69 KB)
π
defs_darwin.go
(3.79 KB)
π
defs_darwin_amd64.go
(6.07 KB)
π
defs_darwin_arm64.go
(3.89 KB)
π
defs_dragonfly.go
(2.63 KB)
π
defs_dragonfly_amd64.go
(3.31 KB)
π
defs_freebsd.go
(3.86 KB)
π
defs_freebsd_386.go
(4.38 KB)
π
defs_freebsd_amd64.go
(4.65 KB)
π
defs_freebsd_arm.go
(3.71 KB)
π
defs_freebsd_arm64.go
(4.03 KB)
π
defs_illumos_amd64.go
(285 B)
π
defs_linux.go
(3.05 KB)
π
defs_linux_386.go
(3.77 KB)
π
defs_linux_amd64.go
(4.28 KB)
π
defs_linux_arm.go
(3.45 KB)
π
defs_linux_arm64.go
(3.21 KB)
π
defs_linux_mips64x.go
(3.24 KB)
π
defs_linux_mipsx.go
(3.21 KB)
π
defs_linux_ppc64.go
(3.28 KB)
π
defs_linux_ppc64le.go
(3.28 KB)
π
defs_linux_riscv64.go
(3.27 KB)
π
defs_linux_s390x.go
(2.76 KB)
π
defs_netbsd.go
(2.76 KB)
π
defs_netbsd_386.go
(872 B)
π
defs_netbsd_amd64.go
(1.03 KB)
π
defs_netbsd_arm.go
(781 B)
π
defs_openbsd.go
(3.1 KB)
π
defs_openbsd_386.go
(2.89 KB)
π
defs_openbsd_amd64.go
(3.09 KB)
π
defs_openbsd_arm.go
(3 KB)
π
defs_openbsd_arm64.go
(2.76 KB)
π
defs_openbsd_mips64.go
(2.66 KB)
π
defs_plan9_386.go
(1.63 KB)
π
defs_plan9_amd64.go
(1.82 KB)
π
defs_plan9_arm.go
(1.73 KB)
π
defs_solaris.go
(3.35 KB)
π
defs_solaris_amd64.go
(1021 B)
π
defs_windows.go
(2.09 KB)
π
defs_windows_386.go
(1.98 KB)
π
defs_windows_amd64.go
(2.71 KB)
π
defs_windows_arm.go
(2.11 KB)
π
defs_windows_arm64.go
(2.63 KB)
π
duff_386.s
(8.24 KB)
π
duff_amd64.s
(5.62 KB)
π
duff_arm.s
(7.11 KB)
π
duff_arm64.s
(5.25 KB)
π
duff_mips64x.s
(11.31 KB)
π
duff_ppc64x.s
(2.43 KB)
π
duff_riscv64.s
(11.38 KB)
π
duff_s390x.s
(507 B)
π
env_plan9.go
(2.99 KB)
π
env_posix.go
(1.95 KB)
π
env_test.go
(1.16 KB)
π
error.go
(9.23 KB)
π
example_test.go
(1.55 KB)
π
export_aix_test.go
(204 B)
π
export_arm_test.go
(226 B)
π
export_darwin_test.go
(351 B)
π
export_debug_regabiargs_off_test.go
(416 B)
π
export_debug_regabiargs_on_test.go
(1.39 KB)
π
export_debug_test.go
(5.86 KB)
π
export_debuglog_test.go
(1.27 KB)
π
export_futex_test.go
(570 B)
π
export_linux_test.go
(429 B)
π
export_mmap_test.go
(571 B)
π
export_pipe2_test.go
(436 B)
π
export_pipe_test.go
(240 B)
π
export_solaris_test.go
(282 B)
π
export_test.go
(30.12 KB)
π
export_unix_test.go
(2.35 KB)
π
export_windows_test.go
(652 B)
π
extern.go
(12.58 KB)
π
fastlog2.go
(1.22 KB)
π
fastlog2_test.go
(784 B)
π
fastlog2table.go
(904 B)
π
float.go
(1.35 KB)
π
funcdata.h
(2.47 KB)
π
futex_test.go
(2.15 KB)
π
gc_test.go
(19.21 KB)
π
gcinfo_test.go
(5.69 KB)
π
go_tls.h
(366 B)
π
hash32.go
(1.61 KB)
π
hash64.go
(2.01 KB)
π
hash_test.go
(16.5 KB)
π
heapdump.go
(17.74 KB)
π
histogram.go
(6.42 KB)
π
histogram_test.go
(1.85 KB)
π
iface.go
(16.13 KB)
π
iface_test.go
(7.51 KB)
π
internal
π
lfstack.go
(1.77 KB)
π
lfstack_32bit.go
(562 B)
π
lfstack_64bit.go
(2.24 KB)
π
lfstack_test.go
(2.78 KB)
π
libfuzzer.go
(2.6 KB)
π
libfuzzer_amd64.s
(961 B)
π
libfuzzer_arm64.s
(772 B)
π
lock_futex.go
(5.22 KB)
π
lock_js.go
(5.81 KB)
π
lock_sema.go
(6.8 KB)
π
lockrank.go
(11.62 KB)
π
lockrank_off.go
(1.17 KB)
π
lockrank_on.go
(9.84 KB)
π
lockrank_test.go
(1.15 KB)
π
malloc.go
(52.33 KB)
π
malloc_test.go
(10.83 KB)
π
map.go
(42.47 KB)
π
map_benchmark_test.go
(10.51 KB)
π
map_fast32.go
(12.63 KB)
π
map_fast64.go
(12.82 KB)
π
map_faststr.go
(14.15 KB)
π
map_test.go
(27.52 KB)
π
mbarrier.go
(12.2 KB)
π
mbitmap.go
(65.27 KB)
π
mcache.go
(9.68 KB)
π
mcentral.go
(7.8 KB)
π
mcheckmark.go
(2.81 KB)
π
mem_aix.go
(1.94 KB)
π
mem_bsd.go
(2.12 KB)
π
mem_darwin.go
(1.88 KB)
π
mem_js.go
(2.35 KB)
π
mem_linux.go
(5.59 KB)
π
mem_plan9.go
(4.53 KB)
π
mem_windows.go
(3.87 KB)
π
memclr_386.s
(2.42 KB)
π
memclr_amd64.s
(3.89 KB)
π
memclr_arm.s
(2.6 KB)
π
memclr_arm64.s
(3.65 KB)
π
memclr_mips64x.s
(1.75 KB)
π
memclr_mipsx.s
(1.35 KB)
π
memclr_plan9_386.s
(983 B)
π
memclr_plan9_amd64.s
(511 B)
π
memclr_ppc64x.s
(4.31 KB)
π
memclr_riscv64.s
(926 B)
π
memclr_s390x.s
(1.96 KB)
π
memclr_wasm.s
(622 B)
π
memmove_386.s
(4.46 KB)
π
memmove_amd64.s
(12.66 KB)
π
memmove_arm.s
(5.9 KB)
π
memmove_arm64.s
(6 KB)
π
memmove_linux_amd64_test.go
(1.6 KB)
π
memmove_mips64x.s
(1.85 KB)
π
memmove_mipsx.s
(4.42 KB)
π
memmove_plan9_386.s
(3.06 KB)
π
memmove_plan9_amd64.s
(3.04 KB)
π
memmove_ppc64x.s
(4.11 KB)
π
memmove_riscv64.s
(1.81 KB)
π
memmove_s390x.s
(2.92 KB)
π
memmove_test.go
(12.04 KB)
π
memmove_wasm.s
(1.74 KB)
π
metrics
π
metrics.go
(17.69 KB)
π
metrics_test.go
(12.48 KB)
π
mfinal.go
(15.76 KB)
π
mfinal_test.go
(5.85 KB)
π
mfixalloc.go
(2.73 KB)
π
mgc.go
(55.18 KB)
π
mgcmark.go
(45.54 KB)
π
mgcpacer.go
(29.56 KB)
π
mgcscavenge.go
(35.05 KB)
π
mgcscavenge_test.go
(12.74 KB)
π
mgcstack.go
(10.58 KB)
π
mgcsweep.go
(23.56 KB)
π
mgcwork.go
(12.82 KB)
π
mheap.go
(66.31 KB)
π
mkduff.go
(7.19 KB)
π
mkfastlog2table.go
(1.32 KB)
π
mkpreempt.go
(14.17 KB)
π
mksizeclasses.go
(9.31 KB)
π
mmap.go
(990 B)
π
mpagealloc.go
(36.77 KB)
π
mpagealloc_32bit.go
(3.81 KB)
π
mpagealloc_64bit.go
(6.65 KB)
π
mpagealloc_test.go
(32.38 KB)
π
mpagecache.go
(5.28 KB)
π
mpagecache_test.go
(9.93 KB)
π
mpallocbits.go
(12.01 KB)
π
mpallocbits_test.go
(13.69 KB)
π
mprof.go
(25.82 KB)
π
mranges.go
(11.84 KB)
π
mranges_test.go
(5.68 KB)
π
msan
π
msan.go
(1.51 KB)
π
msan0.go
(741 B)
π
msan_amd64.s
(2.32 KB)
π
msan_arm64.s
(2.01 KB)
π
msize.go
(777 B)
π
mspanset.go
(12.2 KB)
π
mstats.go
(30.65 KB)
π
mwbbuf.go
(9.3 KB)
π
nbpipe_fcntl_libc_test.go
(499 B)
π
nbpipe_fcntl_unix_test.go
(507 B)
π
nbpipe_pipe.go
(426 B)
π
nbpipe_pipe2.go
(592 B)
π
nbpipe_test.go
(2.26 KB)
π
net_plan9.go
(645 B)
π
netpoll.go
(16.24 KB)
π
netpoll_aix.go
(4.87 KB)
π
netpoll_epoll.go
(4.21 KB)
π
netpoll_fake.go
(670 B)
π
netpoll_kqueue.go
(4.64 KB)
π
netpoll_os_test.go
(360 B)
π
netpoll_solaris.go
(10.75 KB)
π
netpoll_stub.go
(1.42 KB)
π
netpoll_windows.go
(3.75 KB)
π
norace_linux_test.go
(905 B)
π
norace_test.go
(996 B)
π
numcpu_freebsd_test.go
(381 B)
π
os2_aix.go
(20.45 KB)
π
os2_freebsd.go
(302 B)
π
os2_openbsd.go
(296 B)
π
os2_plan9.go
(1.48 KB)
π
os2_solaris.go
(320 B)
π
os3_plan9.go
(3.88 KB)
π
os3_solaris.go
(17.02 KB)
π
os_aix.go
(8.06 KB)
π
os_android.go
(463 B)
π
os_darwin.go
(11.54 KB)
π
os_darwin_arm64.go
(416 B)
π
os_dragonfly.go
(6.46 KB)
π
os_freebsd.go
(11.2 KB)
π
os_freebsd2.go
(507 B)
π
os_freebsd_amd64.go
(529 B)
π
os_freebsd_arm.go
(1.32 KB)
π
os_freebsd_arm64.go
(398 B)
π
os_freebsd_noauxv.go
(264 B)
π
os_illumos.go
(3.93 KB)
π
os_js.go
(3.26 KB)
π
os_linux.go
(13.47 KB)
π
os_linux_arm.go
(1.35 KB)
π
os_linux_arm64.go
(572 B)
π
os_linux_be64.go
(862 B)
π
os_linux_generic.go
(950 B)
π
os_linux_mips64x.go
(1.11 KB)
π
os_linux_mipsx.go
(1.09 KB)
π
os_linux_noauxv.go
(408 B)
π
os_linux_novdso.go
(387 B)
π
os_linux_ppc64x.go
(566 B)
π
os_linux_riscv64.go
(198 B)
π
os_linux_s390x.go
(316 B)
π
os_linux_x86.go
(270 B)
π
os_netbsd.go
(9.09 KB)
π
os_netbsd_386.go
(588 B)
π
os_netbsd_amd64.go
(585 B)
π
os_netbsd_arm.go
(1.13 KB)
π
os_netbsd_arm64.go
(827 B)
π
os_nonopenbsd.go
(456 B)
π
os_only_solaris.go
(376 B)
π
os_openbsd.go
(6.01 KB)
π
os_openbsd_arm.go
(749 B)
π
os_openbsd_arm64.go
(416 B)
π
os_openbsd_libc.go
(1.7 KB)
π
os_openbsd_mips64.go
(416 B)
π
os_openbsd_syscall.go
(1.27 KB)
π
os_openbsd_syscall1.go
(466 B)
π
os_openbsd_syscall2.go
(2.5 KB)
π
os_plan9.go
(10.2 KB)
π
os_plan9_arm.go
(462 B)
π
os_solaris.go
(6.49 KB)
π
os_windows.go
(43.68 KB)
π
os_windows_arm.go
(511 B)
π
os_windows_arm64.go
(339 B)
π
panic.go
(44.28 KB)
π
panic32.go
(4.83 KB)
π
panic_test.go
(1.71 KB)
π
plugin.go
(4.27 KB)
π
pprof
π
preempt.go
(15.4 KB)
π
preempt_386.s
(1.07 KB)
π
preempt_amd64.s
(1.81 KB)
π
preempt_arm.s
(1.66 KB)
π
preempt_arm64.s
(2.99 KB)
π
preempt_mips64x.s
(2.93 KB)
π
preempt_mipsx.s
(2.89 KB)
π
preempt_nonwindows.go
(309 B)
π
preempt_ppc64x.s
(2.92 KB)
π
preempt_riscv64.s
(2.48 KB)
π
preempt_s390x.s
(1.19 KB)
π
preempt_wasm.s
(365 B)
π
print.go
(5.95 KB)
π
proc.go
(181.46 KB)
π
proc_runtime_test.go
(820 B)
π
proc_test.go
(25.02 KB)
π
profbuf.go
(18.26 KB)
π
profbuf_test.go
(8.65 KB)
π
proflabel.go
(1.52 KB)
π
race
π
race.go
(18.56 KB)
π
race0.go
(2.81 KB)
π
race_amd64.s
(14.46 KB)
π
race_arm64.s
(13.71 KB)
π
race_ppc64le.s
(17.72 KB)
π
rand_test.go
(783 B)
π
rdebug.go
(553 B)
π
relax_stub.go
(617 B)
π
rt0_aix_ppc64.s
(4.33 KB)
π
rt0_android_386.s
(822 B)
π
rt0_android_amd64.s
(754 B)
π
rt0_android_arm.s
(843 B)
π
rt0_android_arm64.s
(941 B)
π
rt0_darwin_amd64.s
(399 B)
π
rt0_darwin_arm64.s
(2.27 KB)
π
rt0_dragonfly_amd64.s
(448 B)
π
rt0_freebsd_386.s
(454 B)
π
rt0_freebsd_amd64.s
(442 B)
π
rt0_freebsd_arm.s
(298 B)
π
rt0_freebsd_arm64.s
(2.46 KB)
π
rt0_illumos_amd64.s
(311 B)
π
rt0_ios_amd64.s
(425 B)
π
rt0_ios_arm64.s
(425 B)
π
rt0_js_wasm.s
(2.3 KB)
π
rt0_linux_386.s
(450 B)
π
rt0_linux_amd64.s
(307 B)
π
rt0_linux_arm.s
(1007 B)
π
rt0_linux_arm64.s
(2.39 KB)
π
rt0_linux_mips64x.s
(1.03 KB)
π
rt0_linux_mipsx.s
(835 B)
π
rt0_linux_ppc64.s
(865 B)
π
rt0_linux_ppc64le.s
(3.88 KB)
π
rt0_linux_riscv64.s
(370 B)
π
rt0_linux_s390x.s
(676 B)
π
rt0_netbsd_386.s
(452 B)
π
rt0_netbsd_amd64.s
(309 B)
π
rt0_netbsd_arm.s
(296 B)
π
rt0_netbsd_arm64.s
(2.38 KB)
π
rt0_openbsd_386.s
(454 B)
π
rt0_openbsd_amd64.s
(311 B)
π
rt0_openbsd_arm.s
(298 B)
π
rt0_openbsd_arm64.s
(2.54 KB)
π
rt0_openbsd_mips64.s
(976 B)
π
rt0_plan9_386.s
(523 B)
π
rt0_plan9_amd64.s
(481 B)
π
rt0_plan9_arm.s
(397 B)
π
rt0_solaris_amd64.s
(311 B)
π
rt0_windows_386.s
(1.28 KB)
π
rt0_windows_amd64.s
(986 B)
π
rt0_windows_arm.s
(386 B)
π
rt0_windows_arm64.s
(725 B)
π
runtime-gdb.py
(15.02 KB)
π
runtime-gdb_test.go
(20.19 KB)
π
runtime-lldb_test.go
(4.95 KB)
π
runtime.go
(1.42 KB)
π
runtime1.go
(12.63 KB)
π
runtime2.go
(42.27 KB)
π
runtime_linux_test.go
(1.46 KB)
π
runtime_mmap_test.go
(1.91 KB)
π
runtime_test.go
(7.81 KB)
π
runtime_unix_test.go
(1.29 KB)
π
rwmutex.go
(3.53 KB)
π
rwmutex_test.go
(4.03 KB)
π
select.go
(14.45 KB)
π
sema.go
(16.08 KB)
π
sema_test.go
(2.5 KB)
π
semasleep_test.go
(1.65 KB)
π
sigaction.go
(543 B)
π
signal_386.go
(1.72 KB)
π
signal_aix_ppc64.go
(3.56 KB)
π
signal_amd64.go
(2.71 KB)
π
signal_arm.go
(2.56 KB)
π
signal_arm64.go
(3.16 KB)
π
signal_darwin.go
(2.13 KB)
π
signal_darwin_amd64.go
(3.85 KB)
π
signal_darwin_arm64.go
(3.6 KB)
π
signal_dragonfly.go
(2.17 KB)
π
signal_dragonfly_amd64.go
(2.01 KB)
π
signal_freebsd.go
(2.2 KB)
π
signal_freebsd_386.go
(1.55 KB)
π
signal_freebsd_amd64.go
(2.03 KB)
π
signal_freebsd_arm.go
(2.18 KB)
π
signal_freebsd_arm64.go
(3.23 KB)
π
signal_linux_386.go
(1.59 KB)
π
signal_linux_amd64.go
(2.05 KB)
π
signal_linux_arm.go
(2.13 KB)
π
signal_linux_arm64.go
(2.95 KB)
π
signal_linux_mips64x.go
(3.39 KB)
π
signal_linux_mipsx.go
(3.7 KB)
π
signal_linux_ppc64x.go
(3.46 KB)
π
signal_linux_riscv64.go
(2.92 KB)
π
signal_linux_s390x.go
(4.43 KB)
π
signal_mips64x.go
(3.2 KB)
π
signal_mipsx.go
(3.07 KB)
π
signal_netbsd.go
(2.18 KB)
π
signal_netbsd_386.go
(1.76 KB)
π
signal_netbsd_amd64.go
(2.33 KB)
π
signal_netbsd_arm.go
(2.3 KB)
π
signal_netbsd_arm64.go
(3.4 KB)
π
signal_openbsd.go
(2.18 KB)
π
signal_openbsd_386.go
(1.58 KB)
π
signal_openbsd_amd64.go
(2.04 KB)
π
signal_openbsd_arm.go
(2.12 KB)
π
signal_openbsd_arm64.go
(3.38 KB)
π
signal_openbsd_mips64.go
(3.28 KB)
π
signal_plan9.go
(1.93 KB)
π
signal_ppc64x.go
(3.64 KB)
π
signal_riscv64.go
(2.88 KB)
π
signal_solaris.go
(4.5 KB)
π
signal_solaris_amd64.go
(2.47 KB)
π
signal_unix.go
(37.82 KB)
π
signal_windows.go
(9.2 KB)
π
signal_windows_test.go
(5.73 KB)
π
sigqueue.go
(8.76 KB)
π
sigqueue_note.go
(673 B)
π
sigqueue_plan9.go
(3.39 KB)
π
sigtab_aix.go
(11.3 KB)
π
sigtab_linux_generic.go
(3.56 KB)
π
sigtab_linux_mipsx.go
(6.01 KB)
π
sizeclasses.go
(9.14 KB)
π
sizeof_test.go
(905 B)
π
slice.go
(8.94 KB)
π
slice_test.go
(10.32 KB)
π
softfloat64.go
(10.78 KB)
π
softfloat64_test.go
(4.05 KB)
π
stack.go
(41.92 KB)
π
stack_test.go
(21.05 KB)
π
string.go
(10.85 KB)
π
string_test.go
(9.62 KB)
π
stubs.go
(18.17 KB)
π
stubs2.go
(1.14 KB)
π
stubs3.go
(331 B)
π
stubs_386.go
(550 B)
π
stubs_amd64.go
(1.2 KB)
π
stubs_arm.go
(531 B)
π
stubs_arm64.go
(351 B)
π
stubs_linux.go
(663 B)
π
stubs_mips64x.go
(390 B)
π
stubs_mipsx.go
(305 B)
π
stubs_nonlinux.go
(315 B)
π
stubs_ppc64.go
(383 B)
π
stubs_ppc64le.go
(271 B)
π
stubs_s390x.go
(256 B)
π
symtab.go
(32.29 KB)
π
symtab_test.go
(6.78 KB)
π
sys_aix_ppc64.s
(7.13 KB)
π
sys_arm.go
(521 B)
π
sys_arm64.go
(469 B)
π
sys_darwin.go
(15.91 KB)
π
sys_darwin_amd64.s
(18.52 KB)
π
sys_darwin_arm64.go
(1.68 KB)
π
sys_darwin_arm64.s
(17.23 KB)
π
sys_dragonfly_amd64.s
(8.42 KB)
π
sys_freebsd_386.s
(8.98 KB)
π
sys_freebsd_amd64.s
(10.55 KB)
π
sys_freebsd_arm.s
(10.69 KB)
π
sys_freebsd_arm64.s
(10.33 KB)
π
sys_libc.go
(1.87 KB)
π
sys_linux_386.s
(18.17 KB)
π
sys_linux_amd64.s
(16.25 KB)
π
sys_linux_arm.s
(15.84 KB)
π
sys_linux_arm64.s
(15.26 KB)
π
sys_linux_mips64x.s
(13.4 KB)
π
sys_linux_mipsx.s
(11.16 KB)
π
sys_linux_ppc64x.s
(21.48 KB)
π
sys_linux_riscv64.s
(10.35 KB)
π
sys_linux_s390x.s
(10.52 KB)
π
sys_mips64x.go
(526 B)
π
sys_mipsx.go
(518 B)
π
sys_netbsd_386.s
(10.13 KB)
π
sys_netbsd_amd64.s
(9.91 KB)
π
sys_netbsd_arm.s
(10.94 KB)
π
sys_netbsd_arm64.s
(10.42 KB)
π
sys_nonppc64x.go
(271 B)
π
sys_openbsd.go
(2.3 KB)
π
sys_openbsd1.go
(1.16 KB)
π
sys_openbsd2.go
(7.31 KB)
π
sys_openbsd3.go
(3.29 KB)
π
sys_openbsd_386.s
(19.97 KB)
π
sys_openbsd_amd64.s
(16.44 KB)
π
sys_openbsd_arm.s
(18.09 KB)
π
sys_openbsd_arm64.s
(15.92 KB)
π
sys_openbsd_mips64.s
(9.22 KB)
π
sys_plan9_386.s
(4.4 KB)
π
sys_plan9_amd64.s
(4.47 KB)
π
sys_plan9_arm.s
(7.03 KB)
π
sys_ppc64x.go
(556 B)
π
sys_riscv64.go
(469 B)
π
sys_s390x.go
(469 B)
π
sys_solaris_amd64.s
(6.69 KB)
π
sys_wasm.go
(732 B)
π
sys_wasm.s
(2.65 KB)
π
sys_windows_386.s
(7.74 KB)
π
sys_windows_amd64.s
(9.16 KB)
π
sys_windows_arm.s
(12.02 KB)
π
sys_windows_arm64.s
(12.51 KB)
π
sys_x86.go
(574 B)
π
syscall2_solaris.go
(1.65 KB)
π
syscall_aix.go
(5.99 KB)
π
syscall_solaris.go
(8.26 KB)
π
syscall_windows.go
(16.48 KB)
π
syscall_windows_test.go
(32.53 KB)
π
testdata
π
textflag.h
(1.52 KB)
π
time.go
(30.56 KB)
π
time_fake.go
(2.38 KB)
π
time_linux_amd64.s
(2.18 KB)
π
time_nofake.go
(587 B)
π
time_test.go
(2.03 KB)
π
time_windows.h
(694 B)
π
time_windows_386.s
(1.81 KB)
π
time_windows_amd64.s
(1.07 KB)
π
time_windows_arm.s
(2.07 KB)
π
time_windows_arm64.s
(1.33 KB)
π
timeasm.go
(468 B)
π
timestub.go
(595 B)
π
timestub2.go
(447 B)
π
tls_arm.s
(3.33 KB)
π
tls_arm64.h
(1.22 KB)
π
tls_arm64.s
(1.2 KB)
π
tls_mips64x.s
(759 B)
π
tls_mipsx.s
(731 B)
π
tls_ppc64x.s
(1.52 KB)
π
tls_riscv64.s
(726 B)
π
tls_s390x.s
(1.55 KB)
π
tls_stub.go
(294 B)
π
tls_windows_amd64.go
(294 B)
π
trace
π
trace.go
(38.36 KB)
π
traceback.go
(46.51 KB)
π
traceback_test.go
(8.04 KB)
π
type.go
(18.59 KB)
π
typekind.go
(742 B)
π
utf8.go
(3.39 KB)
π
vdso_elf32.go
(2.79 KB)
π
vdso_elf64.go
(2.87 KB)
π
vdso_freebsd.go
(2.46 KB)
π
vdso_freebsd_arm.go
(454 B)
π
vdso_freebsd_arm64.go
(443 B)
π
vdso_freebsd_x86.go
(1.89 KB)
π
vdso_in_none.go
(490 B)
π
vdso_linux.go
(7.77 KB)
π
vdso_linux_386.go
(669 B)
π
vdso_linux_amd64.go
(685 B)
π
vdso_linux_arm.go
(669 B)
π
vdso_linux_arm64.go
(670 B)
π
vdso_linux_mips64x.go
(892 B)
π
vdso_linux_ppc64x.go
(712 B)
π
vlop_386.s
(2.02 KB)
π
vlop_arm.s
(7.06 KB)
π
vlop_arm_test.go
(3.75 KB)
π
vlrt.go
(5.91 KB)
π
wincallback.go
(3.52 KB)
π
write_err.go
(310 B)
π
write_err_android.go
(4.65 KB)
π
zcallback_windows.go
(155 B)
π
zcallback_windows.s
(63.05 KB)
π
zcallback_windows_arm.s
(89.34 KB)
π
zcallback_windows_arm64.s
(89.34 KB)
Editing: mgcpacer.go
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package runtime import ( "internal/cpu" "runtime/internal/atomic" "unsafe" ) const ( // gcGoalUtilization is the goal CPU utilization for // marking as a fraction of GOMAXPROCS. gcGoalUtilization = 0.30 // gcBackgroundUtilization is the fixed CPU utilization for background // marking. It must be <= gcGoalUtilization. The difference between // gcGoalUtilization and gcBackgroundUtilization will be made up by // mark assists. The scheduler will aim to use within 50% of this // goal. // // Setting this to < gcGoalUtilization avoids saturating the trigger // feedback controller when there are no assists, which allows it to // better control CPU and heap growth. However, the larger the gap, // the more mutator assists are expected to happen, which impact // mutator latency. gcBackgroundUtilization = 0.25 // gcCreditSlack is the amount of scan work credit that can // accumulate locally before updating gcController.scanWork and, // optionally, gcController.bgScanCredit. Lower values give a more // accurate assist ratio and make it more likely that assists will // successfully steal background credit. Higher values reduce memory // contention. gcCreditSlack = 2000 // gcAssistTimeSlack is the nanoseconds of mutator assist time that // can accumulate on a P before updating gcController.assistTime. gcAssistTimeSlack = 5000 // gcOverAssistWork determines how many extra units of scan work a GC // assist does when an assist happens. This amortizes the cost of an // assist by pre-paying for this many bytes of future allocations. gcOverAssistWork = 64 << 10 // defaultHeapMinimum is the value of heapMinimum for GOGC==100. defaultHeapMinimum = 4 << 20 ) func init() { if offset := unsafe.Offsetof(gcController.heapLive); offset%8 != 0 { println(offset) throw("gcController.heapLive not aligned to 8 bytes") } } // gcController implements the GC pacing controller that determines // when to trigger concurrent garbage collection and how much marking // work to do in mutator assists and background marking. // // It uses a feedback control algorithm to adjust the gcController.trigger // trigger based on the heap growth and GC CPU utilization each cycle. // This algorithm optimizes for heap growth to match GOGC and for CPU // utilization between assist and background marking to be 25% of // GOMAXPROCS. The high-level design of this algorithm is documented // at https://golang.org/s/go15gcpacing. // // All fields of gcController are used only during a single mark // cycle. var gcController gcControllerState type gcControllerState struct { // Initialized from $GOGC. GOGC=off means no GC. gcPercent int32 _ uint32 // padding so following 64-bit values are 8-byte aligned // heapMinimum is the minimum heap size at which to trigger GC. // For small heaps, this overrides the usual GOGC*live set rule. // // When there is a very small live set but a lot of allocation, simply // collecting when the heap reaches GOGC*live results in many GC // cycles and high total per-GC overhead. This minimum amortizes this // per-GC overhead while keeping the heap reasonably small. // // During initialization this is set to 4MB*GOGC/100. In the case of // GOGC==0, this will set heapMinimum to 0, resulting in constant // collection even when the heap size is small, which is useful for // debugging. heapMinimum uint64 // triggerRatio is the heap growth ratio that triggers marking. // // E.g., if this is 0.6, then GC should start when the live // heap has reached 1.6 times the heap size marked by the // previous cycle. This should be β€ GOGC/100 so the trigger // heap size is less than the goal heap size. This is set // during mark termination for the next cycle's trigger. // // Protected by mheap_.lock or a STW. triggerRatio float64 // trigger is the heap size that triggers marking. // // When heapLive β₯ trigger, the mark phase will start. // This is also the heap size by which proportional sweeping // must be complete. // // This is computed from triggerRatio during mark termination // for the next cycle's trigger. // // Protected by mheap_.lock or a STW. trigger uint64 // heapGoal is the goal heapLive for when next GC ends. // Set to ^uint64(0) if disabled. // // Read and written atomically, unless the world is stopped. heapGoal uint64 // lastHeapGoal is the value of heapGoal for the previous GC. // Note that this is distinct from the last value heapGoal had, // because it could change if e.g. gcPercent changes. // // Read and written with the world stopped or with mheap_.lock held. lastHeapGoal uint64 // heapLive is the number of bytes considered live by the GC. // That is: retained by the most recent GC plus allocated // since then. heapLive β€ memstats.heapAlloc, since heapAlloc includes // unmarked objects that have not yet been swept (and hence goes up as we // allocate and down as we sweep) while heapLive excludes these // objects (and hence only goes up between GCs). // // This is updated atomically without locking. To reduce // contention, this is updated only when obtaining a span from // an mcentral and at this point it counts all of the // unallocated slots in that span (which will be allocated // before that mcache obtains another span from that // mcentral). Hence, it slightly overestimates the "true" live // heap size. It's better to overestimate than to // underestimate because 1) this triggers the GC earlier than // necessary rather than potentially too late and 2) this // leads to a conservative GC rate rather than a GC rate that // is potentially too low. // // Reads should likewise be atomic (or during STW). // // Whenever this is updated, call traceHeapAlloc() and // this gcControllerState's revise() method. heapLive uint64 // heapScan is the number of bytes of "scannable" heap. This // is the live heap (as counted by heapLive), but omitting // no-scan objects and no-scan tails of objects. // // Whenever this is updated, call this gcControllerState's // revise() method. // // Read and written atomically or with the world stopped. heapScan uint64 // heapMarked is the number of bytes marked by the previous // GC. After mark termination, heapLive == heapMarked, but // unlike heapLive, heapMarked does not change until the // next mark termination. heapMarked uint64 // scanWork is the total scan work performed this cycle. This // is updated atomically during the cycle. Updates occur in // bounded batches, since it is both written and read // throughout the cycle. At the end of the cycle, this is how // much of the retained heap is scannable. // // Currently this is the bytes of heap scanned. For most uses, // this is an opaque unit of work, but for estimation the // definition is important. scanWork int64 // bgScanCredit is the scan work credit accumulated by the // concurrent background scan. This credit is accumulated by // the background scan and stolen by mutator assists. This is // updated atomically. Updates occur in bounded batches, since // it is both written and read throughout the cycle. bgScanCredit int64 // assistTime is the nanoseconds spent in mutator assists // during this cycle. This is updated atomically. Updates // occur in bounded batches, since it is both written and read // throughout the cycle. assistTime int64 // dedicatedMarkTime is the nanoseconds spent in dedicated // mark workers during this cycle. This is updated atomically // at the end of the concurrent mark phase. dedicatedMarkTime int64 // fractionalMarkTime is the nanoseconds spent in the // fractional mark worker during this cycle. This is updated // atomically throughout the cycle and will be up-to-date if // the fractional mark worker is not currently running. fractionalMarkTime int64 // idleMarkTime is the nanoseconds spent in idle marking // during this cycle. This is updated atomically throughout // the cycle. idleMarkTime int64 // markStartTime is the absolute start time in nanoseconds // that assists and background mark workers started. markStartTime int64 // dedicatedMarkWorkersNeeded is the number of dedicated mark // workers that need to be started. This is computed at the // beginning of each cycle and decremented atomically as // dedicated mark workers get started. dedicatedMarkWorkersNeeded int64 // assistWorkPerByte is the ratio of scan work to allocated // bytes that should be performed by mutator assists. This is // computed at the beginning of each cycle and updated every // time heapScan is updated. // // Stored as a uint64, but it's actually a float64. Use // float64frombits to get the value. // // Read and written atomically. assistWorkPerByte uint64 // assistBytesPerWork is 1/assistWorkPerByte. // // Stored as a uint64, but it's actually a float64. Use // float64frombits to get the value. // // Read and written atomically. // // Note that because this is read and written independently // from assistWorkPerByte users may notice a skew between // the two values, and such a state should be safe. assistBytesPerWork uint64 // fractionalUtilizationGoal is the fraction of wall clock // time that should be spent in the fractional mark worker on // each P that isn't running a dedicated worker. // // For example, if the utilization goal is 25% and there are // no dedicated workers, this will be 0.25. If the goal is // 25%, there is one dedicated worker, and GOMAXPROCS is 5, // this will be 0.05 to make up the missing 5%. // // If this is zero, no fractional workers are needed. fractionalUtilizationGoal float64 _ cpu.CacheLinePad } func (c *gcControllerState) init(gcPercent int32) { c.heapMinimum = defaultHeapMinimum // Set a reasonable initial GC trigger. c.triggerRatio = 7 / 8.0 // Fake a heapMarked value so it looks like a trigger at // heapMinimum is the appropriate growth from heapMarked. // This will go into computing the initial GC goal. c.heapMarked = uint64(float64(c.heapMinimum) / (1 + c.triggerRatio)) // This will also compute and set the GC trigger and goal. c.setGCPercent(gcPercent) } // startCycle resets the GC controller's state and computes estimates // for a new GC cycle. The caller must hold worldsema and the world // must be stopped. func (c *gcControllerState) startCycle() { c.scanWork = 0 c.bgScanCredit = 0 c.assistTime = 0 c.dedicatedMarkTime = 0 c.fractionalMarkTime = 0 c.idleMarkTime = 0 // Ensure that the heap goal is at least a little larger than // the current live heap size. This may not be the case if GC // start is delayed or if the allocation that pushed gcController.heapLive // over trigger is large or if the trigger is really close to // GOGC. Assist is proportional to this distance, so enforce a // minimum distance, even if it means going over the GOGC goal // by a tiny bit. if c.heapGoal < c.heapLive+1024*1024 { c.heapGoal = c.heapLive + 1024*1024 } // Compute the background mark utilization goal. In general, // this may not come out exactly. We round the number of // dedicated workers so that the utilization is closest to // 25%. For small GOMAXPROCS, this would introduce too much // error, so we add fractional workers in that case. totalUtilizationGoal := float64(gomaxprocs) * gcBackgroundUtilization c.dedicatedMarkWorkersNeeded = int64(totalUtilizationGoal + 0.5) utilError := float64(c.dedicatedMarkWorkersNeeded)/totalUtilizationGoal - 1 const maxUtilError = 0.3 if utilError < -maxUtilError || utilError > maxUtilError { // Rounding put us more than 30% off our goal. With // gcBackgroundUtilization of 25%, this happens for // GOMAXPROCS<=3 or GOMAXPROCS=6. Enable fractional // workers to compensate. if float64(c.dedicatedMarkWorkersNeeded) > totalUtilizationGoal { // Too many dedicated workers. c.dedicatedMarkWorkersNeeded-- } c.fractionalUtilizationGoal = (totalUtilizationGoal - float64(c.dedicatedMarkWorkersNeeded)) / float64(gomaxprocs) } else { c.fractionalUtilizationGoal = 0 } // In STW mode, we just want dedicated workers. if debug.gcstoptheworld > 0 { c.dedicatedMarkWorkersNeeded = int64(gomaxprocs) c.fractionalUtilizationGoal = 0 } // Clear per-P state for _, p := range allp { p.gcAssistTime = 0 p.gcFractionalMarkTime = 0 } // Compute initial values for controls that are updated // throughout the cycle. c.revise() if debug.gcpacertrace > 0 { assistRatio := float64frombits(atomic.Load64(&c.assistWorkPerByte)) print("pacer: assist ratio=", assistRatio, " (scan ", gcController.heapScan>>20, " MB in ", work.initialHeapLive>>20, "->", c.heapGoal>>20, " MB)", " workers=", c.dedicatedMarkWorkersNeeded, "+", c.fractionalUtilizationGoal, "\n") } } // revise updates the assist ratio during the GC cycle to account for // improved estimates. This should be called whenever gcController.heapScan, // gcController.heapLive, or gcController.heapGoal is updated. It is safe to // call concurrently, but it may race with other calls to revise. // // The result of this race is that the two assist ratio values may not line // up or may be stale. In practice this is OK because the assist ratio // moves slowly throughout a GC cycle, and the assist ratio is a best-effort // heuristic anyway. Furthermore, no part of the heuristic depends on // the two assist ratio values being exact reciprocals of one another, since // the two values are used to convert values from different sources. // // The worst case result of this raciness is that we may miss a larger shift // in the ratio (say, if we decide to pace more aggressively against the // hard heap goal) but even this "hard goal" is best-effort (see #40460). // The dedicated GC should ensure we don't exceed the hard goal by too much // in the rare case we do exceed it. // // It should only be called when gcBlackenEnabled != 0 (because this // is when assists are enabled and the necessary statistics are // available). func (c *gcControllerState) revise() { gcPercent := c.gcPercent if gcPercent < 0 { // If GC is disabled but we're running a forced GC, // act like GOGC is huge for the below calculations. gcPercent = 100000 } live := atomic.Load64(&c.heapLive) scan := atomic.Load64(&c.heapScan) work := atomic.Loadint64(&c.scanWork) // Assume we're under the soft goal. Pace GC to complete at // heapGoal assuming the heap is in steady-state. heapGoal := int64(atomic.Load64(&c.heapGoal)) // Compute the expected scan work remaining. // // This is estimated based on the expected // steady-state scannable heap. For example, with // GOGC=100, only half of the scannable heap is // expected to be live, so that's what we target. // // (This is a float calculation to avoid overflowing on // 100*heapScan.) scanWorkExpected := int64(float64(scan) * 100 / float64(100+gcPercent)) if int64(live) > heapGoal || work > scanWorkExpected { // We're past the soft goal, or we've already done more scan // work than we expected. Pace GC so that in the worst case it // will complete by the hard goal. const maxOvershoot = 1.1 heapGoal = int64(float64(heapGoal) * maxOvershoot) // Compute the upper bound on the scan work remaining. scanWorkExpected = int64(scan) } // Compute the remaining scan work estimate. // // Note that we currently count allocations during GC as both // scannable heap (heapScan) and scan work completed // (scanWork), so allocation will change this difference // slowly in the soft regime and not at all in the hard // regime. scanWorkRemaining := scanWorkExpected - work if scanWorkRemaining < 1000 { // We set a somewhat arbitrary lower bound on // remaining scan work since if we aim a little high, // we can miss by a little. // // We *do* need to enforce that this is at least 1, // since marking is racy and double-scanning objects // may legitimately make the remaining scan work // negative, even in the hard goal regime. scanWorkRemaining = 1000 } // Compute the heap distance remaining. heapRemaining := heapGoal - int64(live) if heapRemaining <= 0 { // This shouldn't happen, but if it does, avoid // dividing by zero or setting the assist negative. heapRemaining = 1 } // Compute the mutator assist ratio so by the time the mutator // allocates the remaining heap bytes up to heapGoal, it will // have done (or stolen) the remaining amount of scan work. // Note that the assist ratio values are updated atomically // but not together. This means there may be some degree of // skew between the two values. This is generally OK as the // values shift relatively slowly over the course of a GC // cycle. assistWorkPerByte := float64(scanWorkRemaining) / float64(heapRemaining) assistBytesPerWork := float64(heapRemaining) / float64(scanWorkRemaining) atomic.Store64(&c.assistWorkPerByte, float64bits(assistWorkPerByte)) atomic.Store64(&c.assistBytesPerWork, float64bits(assistBytesPerWork)) } // endCycle computes the trigger ratio for the next cycle. // userForced indicates whether the current GC cycle was forced // by the application. func (c *gcControllerState) endCycle(userForced bool) float64 { if userForced { // Forced GC means this cycle didn't start at the // trigger, so where it finished isn't good // information about how to adjust the trigger. // Just leave it where it is. return c.triggerRatio } // Proportional response gain for the trigger controller. Must // be in [0, 1]. Lower values smooth out transient effects but // take longer to respond to phase changes. Higher values // react to phase changes quickly, but are more affected by // transient changes. Values near 1 may be unstable. const triggerGain = 0.5 // Compute next cycle trigger ratio. First, this computes the // "error" for this cycle; that is, how far off the trigger // was from what it should have been, accounting for both heap // growth and GC CPU utilization. We compute the actual heap // growth during this cycle and scale that by how far off from // the goal CPU utilization we were (to estimate the heap // growth if we had the desired CPU utilization). The // difference between this estimate and the GOGC-based goal // heap growth is the error. goalGrowthRatio := c.effectiveGrowthRatio() actualGrowthRatio := float64(c.heapLive)/float64(c.heapMarked) - 1 assistDuration := nanotime() - c.markStartTime // Assume background mark hit its utilization goal. utilization := gcBackgroundUtilization // Add assist utilization; avoid divide by zero. if assistDuration > 0 { utilization += float64(c.assistTime) / float64(assistDuration*int64(gomaxprocs)) } triggerError := goalGrowthRatio - c.triggerRatio - utilization/gcGoalUtilization*(actualGrowthRatio-c.triggerRatio) // Finally, we adjust the trigger for next time by this error, // damped by the proportional gain. triggerRatio := c.triggerRatio + triggerGain*triggerError if debug.gcpacertrace > 0 { // Print controller state in terms of the design // document. H_m_prev := c.heapMarked h_t := c.triggerRatio H_T := c.trigger h_a := actualGrowthRatio H_a := c.heapLive h_g := goalGrowthRatio H_g := int64(float64(H_m_prev) * (1 + h_g)) u_a := utilization u_g := gcGoalUtilization W_a := c.scanWork print("pacer: H_m_prev=", H_m_prev, " h_t=", h_t, " H_T=", H_T, " h_a=", h_a, " H_a=", H_a, " h_g=", h_g, " H_g=", H_g, " u_a=", u_a, " u_g=", u_g, " W_a=", W_a, " goalΞ=", goalGrowthRatio-h_t, " actualΞ=", h_a-h_t, " u_a/u_g=", u_a/u_g, "\n") } return triggerRatio } // enlistWorker encourages another dedicated mark worker to start on // another P if there are spare worker slots. It is used by putfull // when more work is made available. // //go:nowritebarrier func (c *gcControllerState) enlistWorker() { // If there are idle Ps, wake one so it will run an idle worker. // NOTE: This is suspected of causing deadlocks. See golang.org/issue/19112. // // if atomic.Load(&sched.npidle) != 0 && atomic.Load(&sched.nmspinning) == 0 { // wakep() // return // } // There are no idle Ps. If we need more dedicated workers, // try to preempt a running P so it will switch to a worker. if c.dedicatedMarkWorkersNeeded <= 0 { return } // Pick a random other P to preempt. if gomaxprocs <= 1 { return } gp := getg() if gp == nil || gp.m == nil || gp.m.p == 0 { return } myID := gp.m.p.ptr().id for tries := 0; tries < 5; tries++ { id := int32(fastrandn(uint32(gomaxprocs - 1))) if id >= myID { id++ } p := allp[id] if p.status != _Prunning { continue } if preemptone(p) { return } } } // findRunnableGCWorker returns a background mark worker for _p_ if it // should be run. This must only be called when gcBlackenEnabled != 0. func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g { if gcBlackenEnabled == 0 { throw("gcControllerState.findRunnable: blackening not enabled") } if !gcMarkWorkAvailable(_p_) { // No work to be done right now. This can happen at // the end of the mark phase when there are still // assists tapering off. Don't bother running a worker // now because it'll just return immediately. return nil } // Grab a worker before we commit to running below. node := (*gcBgMarkWorkerNode)(gcBgMarkWorkerPool.pop()) if node == nil { // There is at least one worker per P, so normally there are // enough workers to run on all Ps, if necessary. However, once // a worker enters gcMarkDone it may park without rejoining the // pool, thus freeing a P with no corresponding worker. // gcMarkDone never depends on another worker doing work, so it // is safe to simply do nothing here. // // If gcMarkDone bails out without completing the mark phase, // it will always do so with queued global work. Thus, that P // will be immediately eligible to re-run the worker G it was // just using, ensuring work can complete. return nil } decIfPositive := func(ptr *int64) bool { for { v := atomic.Loadint64(ptr) if v <= 0 { return false } if atomic.Casint64(ptr, v, v-1) { return true } } } if decIfPositive(&c.dedicatedMarkWorkersNeeded) { // This P is now dedicated to marking until the end of // the concurrent mark phase. _p_.gcMarkWorkerMode = gcMarkWorkerDedicatedMode } else if c.fractionalUtilizationGoal == 0 { // No need for fractional workers. gcBgMarkWorkerPool.push(&node.node) return nil } else { // Is this P behind on the fractional utilization // goal? // // This should be kept in sync with pollFractionalWorkerExit. delta := nanotime() - c.markStartTime if delta > 0 && float64(_p_.gcFractionalMarkTime)/float64(delta) > c.fractionalUtilizationGoal { // Nope. No need to run a fractional worker. gcBgMarkWorkerPool.push(&node.node) return nil } // Run a fractional worker. _p_.gcMarkWorkerMode = gcMarkWorkerFractionalMode } // Run the background mark worker. gp := node.gp.ptr() casgstatus(gp, _Gwaiting, _Grunnable) if trace.enabled { traceGoUnpark(gp, 0) } return gp } // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. // // This can be called any time. If GC is the in the middle of a // concurrent phase, it will adjust the pacing of that phase. // // This depends on gcPercent, gcController.heapMarked, and // gcController.heapLive. These must be up to date. // // mheap_.lock must be held or the world must be stopped. func (c *gcControllerState) commit(triggerRatio float64) { assertWorldStoppedOrLockHeld(&mheap_.lock) // Compute the next GC goal, which is when the allocated heap // has grown by GOGC/100 over the heap marked by the last // cycle. goal := ^uint64(0) if c.gcPercent >= 0 { goal = c.heapMarked + c.heapMarked*uint64(c.gcPercent)/100 } // Set the trigger ratio, capped to reasonable bounds. if c.gcPercent >= 0 { scalingFactor := float64(c.gcPercent) / 100 // Ensure there's always a little margin so that the // mutator assist ratio isn't infinity. maxTriggerRatio := 0.95 * scalingFactor if triggerRatio > maxTriggerRatio { triggerRatio = maxTriggerRatio } // If we let triggerRatio go too low, then if the application // is allocating very rapidly we might end up in a situation // where we're allocating black during a nearly always-on GC. // The result of this is a growing heap and ultimately an // increase in RSS. By capping us at a point >0, we're essentially // saying that we're OK using more CPU during the GC to prevent // this growth in RSS. // // The current constant was chosen empirically: given a sufficiently // fast/scalable allocator with 48 Ps that could drive the trigger ratio // to <0.05, this constant causes applications to retain the same peak // RSS compared to not having this allocator. minTriggerRatio := 0.6 * scalingFactor if triggerRatio < minTriggerRatio { triggerRatio = minTriggerRatio } } else if triggerRatio < 0 { // gcPercent < 0, so just make sure we're not getting a negative // triggerRatio. This case isn't expected to happen in practice, // and doesn't really matter because if gcPercent < 0 then we won't // ever consume triggerRatio further on in this function, but let's // just be defensive here; the triggerRatio being negative is almost // certainly undesirable. triggerRatio = 0 } c.triggerRatio = triggerRatio // Compute the absolute GC trigger from the trigger ratio. // // We trigger the next GC cycle when the allocated heap has // grown by the trigger ratio over the marked heap size. trigger := ^uint64(0) if c.gcPercent >= 0 { trigger = uint64(float64(c.heapMarked) * (1 + triggerRatio)) // Don't trigger below the minimum heap size. minTrigger := c.heapMinimum if !isSweepDone() { // Concurrent sweep happens in the heap growth // from gcController.heapLive to trigger, so ensure // that concurrent sweep has some heap growth // in which to perform sweeping before we // start the next GC cycle. sweepMin := atomic.Load64(&c.heapLive) + sweepMinHeapDistance if sweepMin > minTrigger { minTrigger = sweepMin } } if trigger < minTrigger { trigger = minTrigger } if int64(trigger) < 0 { print("runtime: heapGoal=", c.heapGoal, " heapMarked=", c.heapMarked, " gcController.heapLive=", c.heapLive, " initialHeapLive=", work.initialHeapLive, "triggerRatio=", triggerRatio, " minTrigger=", minTrigger, "\n") throw("trigger underflow") } if trigger > goal { // The trigger ratio is always less than GOGC/100, but // other bounds on the trigger may have raised it. // Push up the goal, too. goal = trigger } } // Commit to the trigger and goal. c.trigger = trigger atomic.Store64(&c.heapGoal, goal) if trace.enabled { traceHeapGoal() } // Update mark pacing. if gcphase != _GCoff { c.revise() } // Update sweep pacing. if isSweepDone() { mheap_.sweepPagesPerByte = 0 } else { // Concurrent sweep needs to sweep all of the in-use // pages by the time the allocated heap reaches the GC // trigger. Compute the ratio of in-use pages to sweep // per byte allocated, accounting for the fact that // some might already be swept. heapLiveBasis := atomic.Load64(&c.heapLive) heapDistance := int64(trigger) - int64(heapLiveBasis) // Add a little margin so rounding errors and // concurrent sweep are less likely to leave pages // unswept when GC starts. heapDistance -= 1024 * 1024 if heapDistance < _PageSize { // Avoid setting the sweep ratio extremely high heapDistance = _PageSize } pagesSwept := atomic.Load64(&mheap_.pagesSwept) pagesInUse := atomic.Load64(&mheap_.pagesInUse) sweepDistancePages := int64(pagesInUse) - int64(pagesSwept) if sweepDistancePages <= 0 { mheap_.sweepPagesPerByte = 0 } else { mheap_.sweepPagesPerByte = float64(sweepDistancePages) / float64(heapDistance) mheap_.sweepHeapLiveBasis = heapLiveBasis // Write pagesSweptBasis last, since this // signals concurrent sweeps to recompute // their debt. atomic.Store64(&mheap_.pagesSweptBasis, pagesSwept) } } gcPaceScavenger() } // effectiveGrowthRatio returns the current effective heap growth // ratio (GOGC/100) based on heapMarked from the previous GC and // heapGoal for the current GC. // // This may differ from gcPercent/100 because of various upper and // lower bounds on gcPercent. For example, if the heap is smaller than // heapMinimum, this can be higher than gcPercent/100. // // mheap_.lock must be held or the world must be stopped. func (c *gcControllerState) effectiveGrowthRatio() float64 { assertWorldStoppedOrLockHeld(&mheap_.lock) egogc := float64(atomic.Load64(&c.heapGoal)-c.heapMarked) / float64(c.heapMarked) if egogc < 0 { // Shouldn't happen, but just in case. egogc = 0 } return egogc } // setGCPercent updates gcPercent and all related pacer state. // Returns the old value of gcPercent. // // The world must be stopped, or mheap_.lock must be held. func (c *gcControllerState) setGCPercent(in int32) int32 { assertWorldStoppedOrLockHeld(&mheap_.lock) out := c.gcPercent if in < 0 { in = -1 } c.gcPercent = in c.heapMinimum = defaultHeapMinimum * uint64(c.gcPercent) / 100 // Update pacing in response to gcPercent change. c.commit(c.triggerRatio) return out } //go:linkname setGCPercent runtime/debug.setGCPercent func setGCPercent(in int32) (out int32) { // Run on the system stack since we grab the heap lock. systemstack(func() { lock(&mheap_.lock) out = gcController.setGCPercent(in) unlock(&mheap_.lock) }) // If we just disabled GC, wait for any concurrent GC mark to // finish so we always return with no GC running. if in < 0 { gcWaitOnMark(atomic.Load(&work.cycles)) } return out } func readGOGC() int32 { p := gogetenv("GOGC") if p == "off" { return -1 } if n, ok := atoi32(p); ok { return n } return 100 }
Upload File
Create Folder