Writes to mmap-ed files on Linux can cause JVM garbage collection pauses
C Java Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
MakeGarbage.java
README.md
diskload.sh
mmapwritepause.c

README.md

Pauses when writing mmap-ed files

See my blog post for details.

  1. Start a new Ubuntu image.
  2. Run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install linux-virtual gcc screen openjdk-8-jdk
sudo reboot
  1. Copy these files to this machine.
  2. gcc --std=gnu99 -O3 -Wall -Wextra -o mmapwritepause mmapwritepause.c
  3. Start screen. In one terminal: ./mmapwritepause /tmp/mmapout
  4. In another terminal: ./diskload.sh
  5. Watch the output of mmapwritepause; it will print long pauses.

JVM reproduction

  1. javac MakeGarbage.java
  2. java -XX:+PrintGCDetails -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -Xmx1G -Xms1G MakeGarbage
  3. In another terminal, run ./diskload.sh

This will show large safepoint times, correlated with when mmapwritepause reports pauses. To verify that disabling the stats fixes the problem, add -XX:+PerfDisableSharedMem and rerun it.