go/src
Austin Clements 5333550bdc runtime: implement efficient page reclaimer
When we attempt to allocate an N page span (either for a large
allocation or when an mcentral runs dry), we first try to sweep spans
to release N pages. Currently, this can be extremely expensive:
sweeping a span to emptiness is the hardest thing to ask for and the
sweeper generally doesn't know where to even look for potentially
fruitful results. Since this is on the critical path of many
allocations, this is unfortunate.

This CL changes how we reclaim empty spans. Instead of trying lots of
spans and hoping for the best, it uses the newly introduced span marks
to efficiently find empty spans. The span marks (and in-use bits) are
in a dense bitmap, so these spans can be found with an efficient
sequential memory scan. This approach can scan for unmarked spans at
about 300 GB/ms and can free unmarked spans at about 32 MB/ms. We
could probably significantly improve the rate at which is can free
unmarked spans, but that's a separate issue.

Like the current reclaimer, this is still linear in the number of
spans that are swept, but the constant factor is now so vanishingly
small that it doesn't matter.

The benchmark in #18155 demonstrates both significant page reclaiming
delays, and object reclaiming delays. With "-retain-count=20000000
-preallocate=true -loop-count=3", the benchmark demonstrates several
page reclaiming delays on the order of 40ms. After this change, the
page reclaims are insignificant. The longest sweeps are still ~150ms,
but are object reclaiming delays. We'll address those in the next
several CLs.

Updates #18155.

Fixes #21378 by completely replacing the logic that had that bug.

Change-Id: Iad80eec11d7fc262d02c8f0761ac6998425c4064
Reviewed-on: https://go-review.googlesource.com/c/138959
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2018-11-15 19:27:11 +00:00
..
archive
bufio bufio: make Reader.Peek invalidate Unreads 2018-11-13 15:08:13 +00:00
builtin
bytes strings,bytes: use inlineable function trampolines instead of linkname 2018-11-08 20:52:47 +00:00
cmd cmd/vet/all: use x/tools/go/analysis/cmd/vet not cmd/vet 2018-11-15 18:46:33 +00:00
compress
container container/heap: adjust wording in comments 2018-11-13 13:42:59 +00:00
context
crypto crypto/tls: don't modify Config.Certificates in BuildNameToCertificate 2018-11-12 23:25:21 +00:00
database/sql database/sql: add support for returning cursors to client 2018-11-08 21:19:17 +00:00
debug debug/gosym: use "go build" instead of hand-running asm and link 2018-11-12 20:27:20 +00:00
encoding all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
errors
expvar
flag flag: return a consistent parse error if the flag value is invalid 2018-10-19 03:48:38 +00:00
fmt fmt: avoid allocation when formatting byte slice arguments with verb s 2018-11-14 20:32:15 +00:00
go go/build: do not suggest runtime.Version in comment 2018-11-13 13:35:15 +00:00
hash hash/crc64: use t.Fatalf in TestGolden 2018-10-25 06:32:12 +00:00
html all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
image jpeg: simplify 'x = x op ...' to 'x op= ...' 2018-10-13 11:18:56 +00:00
index/suffixarray
internal internal/cpu: move GODEBUGCPU options into GODEBUG 2018-11-14 21:47:50 +00:00
io
log log: add Logger.Writer method 2018-10-25 23:23:57 +00:00
math all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
mime mime/multipart: check for quoted-printable case insensitively 2018-11-09 05:37:10 +00:00
net net/http: make Transport respect {X-,}Idempotency-Key header 2018-11-14 21:07:02 +00:00
os Revert "os: remove sleep in windows Process.Wait" 2018-11-09 23:24:35 +00:00
path all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
plugin
reflect runtime, reflect: access runtime.reflectcall directly 2018-11-12 20:27:14 +00:00
regexp all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
runtime runtime: implement efficient page reclaimer 2018-11-15 19:27:11 +00:00
sort
strconv strconv: add comment explaining bounded shift in formatBits 2018-10-15 21:45:52 +00:00
strings strings,bytes: use inlineable function trampolines instead of linkname 2018-11-08 20:52:47 +00:00
sync all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
syscall runtime: correct ABI information for all functions 2018-11-12 20:27:18 +00:00
testdata
testing testing: implement -benchtime=100x 2018-10-12 17:48:31 +00:00
text text/template/parse: simplify Tree.pipeline 2018-10-29 12:20:11 +00:00
time time: add a missing comma in the documentation of Time 2018-11-08 18:02:11 +00:00
unicode
unsafe cmd/compile: assume unsafe pointer arithmetic generates non-nil results 2018-11-14 21:01:36 +00:00
vendor/golang_org/x x/net/route: use libc calls on Darwin 2018-11-14 22:39:08 +00:00
Make.dist
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash
make.bat
make.rc
naclmake.bash
nacltest.bash
race.bash cmd,runtime: enable race detector on arm64 2018-11-13 16:57:22 +00:00
race.bat
run.bash
run.bat
run.rc