Tuesday, January 26, 2021

Solaris 11.4 - Oracle ZFS Buffer Cache and App Memory Hints

Solaris 11.4 - Oracle ZFS Buffer Cache and App Memory Hints

Abstract:

Solaris has long used the UFS File System as the default for root disks. This filesystem placed I/O buffers in the "free space", causing misleading performance problems for Disk I/O when there was seemingly plenty of memory left. This was remedied by ZFS, where disk I/O buffers are counted as used buffer, truly showing only "wasted" memory as free memory. This causes a problem for some applications (i.e. Oracle RDBMS Installers), which attempt to determine how much free space is available before performing an application installation. There is a "work around" for these broken applications.

Background:

An excellent document to understand the use of memory is available from Oracle:
Memory Management Between ZFS and Applications in Oracle Solaris 11.x (Doc ID 1663862.1)

It is not the objective of this blog to re-explain this document, merely show what has not been included by Oracle, for manually making adjustments to the memory usage.

Determining Memory Usage:

One can determine the memory available for any version of Solaris with:

sun9999/root# prtconf | nawk '/Memory/'
Memory size: 32768 Megabytes

And determine the usage by different aspects of Solaris with:

sun9999/root# echo "::memstat" | mdb -k

Usage Type/SubtypePagesBytes%Tot%Tot/%Subt
---------------------------- ---------------- -------- ----- -----------

Kernel5859074.47g 13.9%

Regular Kernel4328743.3g10.3%/73.8%

Defdump prealloc1530331.17g3.6%/26.1%

ZFS306391823.4g 73.0%

User/Anon2692622.05g6.4%

Exec and libs436934.1m0.1%

Page Cache20525160m0.4%

Free (cachelist)14076110m0.3%

Free2351611.79g5.6%

Regular Free2321511.77g5.5%/98.7%

Physical pool reserved mem301023.5m0.0%/ 1.2%

Total419430432g100%

Note: 5.6% is wasted memory, out of the 32Gig total, but some 23.4G /73% can be used, if requested.

The application must request the memory, for it to be available, if it can not interrogate now much it can request from the kernel.

What to Do if an App Fails to Start

Option 1: Reboot

If an application fails to start, like an Oracle RDBMS Installer, because it is not smart enough to determine most of the memory is free, you can temporarily flush the ZFS Adaptive Read Cache (ARC) by rebooting the boot.

The system will flush the cache and there will be plenty of memory available for the installer.

Option 2: Dynamically Tune

Oracle Solaris 11.4 created a new tunable called "user_reserve_hint_pct", which requests the OS to dynamically reserve a percentage of the memory for the application by flushing the ARC.

There is a danger: do not reserve more memory for the user processes than the Kernel & OS require!

Step 1: Determine default value (should be 0)

sun9999/root# echo "user_reserve_hint_pct/D" | mdb -k
user_reserve_hint_pct:

user_reserve_hint_pct:0

Step 2: Select value from determined memory usage (ZFS 73 - Free 5.6 = ~67%, round down 65%)

sun9999/root# echo "user_reserve_hint_pct/W0t65" | mdb -k
user_reserve_hint_pct:

user_reserve_hint_pct:65


sun9999/root# echo "::memstat" | mdb -k

Usage Type/SubtypePagesBytes%Tot%Tot/%Subt
---------------------------- ---------------- -------- ----- -----------

Kernel5995724.57g 14.2%

Regular Kernel4465393.41g10.6%/74.4%

Defdump prealloc1530331.17g3.6%/25.5%

ZFS5473324.18g 13.0%

User/Anon2687342.05g6.4%

Exec and libs435934.1m0.1%

Page Cache20190158m0.4%

Free (cachelist)13903109m0.3%

Free273913420.9g 65.3%

Regular Free273611820.9g65.2%/99.8%

Physical pool reserved mem301623.6m0.0%/ 0.1%

Total419430432g100%

Step 3: Revert Value to Default since much of the the ARC cache has been flushed.

sun9999/root# echo "user_reserve_hint_pct/W0t0" | mdb -kw
user_reserve_hint_pct:0x41=0x0

sun9999/root# echo "user_reserve_hint_pct/D" | mdb -k
user_reserve_hint_pct:

user_reserve_hint_pct:0

At this point, the application should be able to be dynamically tuned.

Conclusion:

Oracle Solaris provides an incredibly tunable environment for running applications, including legacy applications, which are not quite smart enough to understand the benefits of the underlying OS.



No comments:

Post a Comment

[フレーム]

Subscribe to: Post Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /