[Bug 275594] High CPU usage by arc_prune; analysis and fix

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 29 Feb 2024 05:04:27 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275594

--- Comment #68 from Seigo Tanimura <seigo.tanimura@gmail.com> ---
(In reply to Peter Much from comment #67)

Thanks a lot for your test results and my apology for the delayed response.

Your results look just as expected.

> I'm a bit worried the thing is still reluctant to page out, but otherwise this looks good.

Some CPU usage by the ARC eviction, pruning and pagedaemon threads are still
expected.  My fix is meant to keep them form running out of control.

On the FreeBSD ZFS implementation, there are two triggers on the ARC eviction
and pruning:

1. The size reduction of ARC after adding new blocks to it.

This is a part of the original ARC implementation by ZFS, intended to maintain
the ARC size. This usually happens along with the ZFS activities.

2. The vm_lowmem kernel event.

This is the case when either the free VM pages or the kernel memory (malloc(9),
uma(9), etc.) get low, and reclaims the kernel memory used by ZFS.  You can
hence see this behaviour even when ZFS is idle.  There are some other kernel
processes and threads that start by this trigger, including pagedaemon and
nullfs(5) with my fix.

Case 2 has to be handled carefully.  On FreeBSD ZFS, the pagedaemon thread
blocks until ZFS either achieves some eviction or gives up completely.  The ARC
eviction and pruning must work more aggressively in such the case, while
avoiding to starve the application threads.  My fix addresses this issue in the
following ways:

- Prune every single ZFS vnodes. (Work aggressively)
- Pause 1 second before repeating above. (Avoid application starve)

The results of this fix include the dynamic change of the CPU usage by the ARC
eviction and pruning threads.  This may be seen more clearly by top(1) with a
fractional interval. (I have not tryed, though)

-- 
You are receiving this mail because:
You are the assignee for the bug.