Skip to content

jitv2: stop retrying MADV_COLLAPSE once it fails for lack of memory - #801

Open
jamesbraid wants to merge 1 commit into
mainfrom
perf/jitv2-collapse-retry
Open

jamesbraid wants to merge 1 commit into
mainfrom
perf/jitv2-collapse-retry

Conversation

@jamesbraid

Copy link
Copy Markdown
Collaborator

The compile thread calls madvise(MADV_COLLAPSE) on each fully sealed
2 MiB of the code arena, to put sealed code on hugepages and cut iTLB
misses. The arena is PROT_NONE, then RW per commit, then RX per sealed
page, so fault-time hugepages cannot form across those mappings and
this call is the only thing that can give the arena any.

On a host with fragmented free memory every call fails, slowly. On a
224-CPU shared host (93 percent of compaction attempts failing
host-wide), an iris-bench run --quick --cpu r10000 made 6 collapse
calls under strace -T. They took 0.004 to 1.17 s each and all returned
ENOMEM, so each stalled the compile thread and collapsed nothing.
A profile of an O2 PROM boot window on that host showed 46 percent of
samples in the kernel's compaction spinlock; I could not reproduce
that figure on a quieter day, where compaction was about 0.6 percent of
samples.

After the first ENOMEM, EAGAIN or EBUSY, stop calling it for that
arena. A host where collapse works keeps the hugepages; a fragmented
one pays for at most one failed attempt. No speed claim beyond that.

Fixes: 81cd871 ("soa bitmap to aos flag for compile/valid/deny bits ...")

The compile thread calls madvise(MADV_COLLAPSE) on each fully sealed
2 MiB of the code arena, to put sealed code on hugepages and cut iTLB
misses. The arena is PROT_NONE, then RW per commit, then RX per sealed
page, so fault-time hugepages cannot form across those mappings and
this call is the only thing that can give the arena any.

On a host with fragmented free memory every call fails, slowly. On a
224-CPU shared host (93 percent of compaction attempts failing
host-wide), an iris-bench run --quick --cpu r10000 made 6 collapse
calls under strace -T. They took 0.004 to 1.17 s each and all returned
ENOMEM, so each stalled the compile thread and collapsed nothing.
A profile of an O2 PROM boot window on that host showed 46 percent of
samples in the kernel's compaction spinlock; I could not reproduce
that figure on a quieter day, where compaction was about 0.6 percent of
samples.

After the first ENOMEM, EAGAIN or EBUSY, stop calling it for that
arena. A host where collapse works keeps the hugepages; a fragmented
one pays for at most one failed attempt. No speed claim beyond that.

Fixes: 81cd871 ("soa bitmap to aos flag for compile/valid/deny bits ...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant