‹ BackHN Continuity

Thread

A 40ms Go garbage collector pause caused by swap

94 points · 92 comments · shellpipe

  1. jacobgold · · focus · HN ↗
    "It hurts when I do this"

    "Stop doing that"

    If you care about latency, disable swap. System wide or for the specific the cgroup.

    1. delamon · · focus · HN ↗
      This is not entirely correct. If you care about latency, then it doesn't matter on which major fault your application gets paused. Disabling swap protects you from data pages being evicted, but code pages can still be paged out.

      If you care about latency, mlock() your memory, do not disable swap. Swap is good and gives the kernel an equal opportunity to evict data and code pages.

      1. xxs · · focus · HN ↗
        For GC enabled languages swap is universally bad. Some gc-pauses are indistinguishable from a system crash. It's a side effect on not having tightly specified memory limits.

        I'd rather have applications be oom_killed than having them swap out, the former is rather obvious and demands action.

        1. delamon · · focus · HN ↗
          If you want you application to stay in memory, then make it explicitly with mlock()/mlockall().

          Disabling swap will just moves pressere elsewhere: to code pages. And evicted code page is no better: full stall while kernel loads that page from disk.

          1. xaduha · · focus · HN ↗
            I think discussing it in a vacuum is pointless, it should depend on how much memory you have. You can have a swap on, but with a low `vm.swappiness` number.
            1. blueflow · · focus · HN ↗
              The point is that disabling swap does not prevent page eviction. Instead of swap, this discussion should be about the page cache.
              1. xaduha · · focus · HN ↗
                Surely as long as it is all in memory these pauses are not going to be that significant, details like that should be left for the language devs to optimize.

                You can tell an average Golang user to use mutexes, you shouldn't be telling them to lock memory manually.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.