Skip to content

Commit 8a82531

Browse files
authored
Merge pull request #600 from percona/ps-10284-8.4
PS-10284 [DOCS] - add information about jemalloc in 8.4
2 parents 73a17a0 + fb2eeb1 commit 8a82531

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

docs/jemalloc-profiling.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ As root, customize jemalloc with the following flags:
1010

1111
| Option | Description |
1212
| ----------------- | ---------------------------------- |
13-
| enable-stats | Enables statistics-gathering ability |
14-
| enable-prof | Enables heap profiling and the ability to detect leaks.|
13+
| --enable-stats | Enables statistics-gathering ability |
14+
| --enable-prof | Enables heap profiling and the ability to detect leaks.|
1515

16-
Using `LD_PRELOAD`. Build the library, configure the malloc configuration with the `prof:true` string, and then use `LD_PRELOAD` to preload the `libjemalloc.so` library. The libprocess `MemoryProfiler` class detects the library automatically and enables the profiling support.
16+
Using `LD_PRELOAD`. Build the library, configure the malloc configuration with the `prof:true` string, and then use `LD_PRELOAD` to preload the `libjemalloc.so` library. Percona Server for MySQL detects jemalloc with profiling enabled automatically when properly configured.
1717

1818
The following is an example of the required commands:
1919

@@ -40,7 +40,7 @@ To enable jemalloc profiling in a MySQL client, run the following command:
4040
set global jemalloc_profiling=on;
4141
```
4242

43-
The malloc_stats_totals table returns the statistics, in bytes, of the memory usage. The command takes no parameters and returns the results as a table.
43+
The `malloc_stats_totals` table provides statistics, in bytes, of the memory usage.
4444

4545
The following example commands display this result:
4646

@@ -55,15 +55,15 @@ SELECT * FROM malloc_stats_totals;
5555
??? example "Expected output"
5656

5757
```{.text .no-copy}
58-
+----+------------+------------+------------+-------------+------------+
59-
| id | ALLOCATION | MAPPED | RESIDENT | RETAINED | METADATA |
60-
+----+------------+------------+------------+-------------+------------+
61-
| 1 | 390977528 | 405291008 | 520167424 | 436813824 | 9933744 |
62-
+----+------------+------------+------------+-------------+------------+
58+
+------------+------------+------------+------------+-------------+------------+
59+
| ALLOCATED | ACTIVE | MAPPED | RESIDENT | RETAINED | METADATA |
60+
+------------+------------+------------+------------+-------------+------------+
61+
| 390977528 | 391012352 | 405291008 | 520167424 | 436813824 | 9933744 |
62+
+------------+------------+------------+------------+-------------+------------+
6363
1 row in set (0.00 sec)
6464
```
6565

66-
The [malloc_stats](#malloc_stats) table returns the cumulative totals, in bytes, of several statistics per type of arena. The command takes no parameters and returns the results as a table.
66+
The [malloc_stats](#malloc_stats) table provides cumulative totals, in bytes, of several statistics per allocation size type (small, large, and huge).
6767

6868
The following example commands display this result:
6969

@@ -156,15 +156,15 @@ The current stats for allocations. All measurements are in bytes.
156156
| Column Name | Description |
157157
| -------------------- | ------------------------------------------------------------------- |
158158
| ALLOCATED | The total amount the application allocated |
159-
| ACTIVE | The total amount allocated by the application of active pages. A multiple of the page size and this value is greater than or equal to the stats.allocated value. The sum does not include allocator metadata pages and stats.arenas.<i>.pdirty or stats.arenas.<i>.pmuzzy. |
159+
| ACTIVE | The total amount allocated by the application of active pages. A multiple of the page size and this value is greater than or equal to the stats.allocated value. The sum does not include allocator metadata pages and stats.arenas.[i].pdirty or stats.arenas.[i].pmuzzy. |
160160
| MAPPED | The total amount in chunks that are mapped by the allocator in active extents. This value does not include inactive chunks. The value is at least as large as the stats.active and is a multiple of the chunk size. |
161161
| RESIDENT | A maximum number the allocator has mapped in physically resident data pages. All allocator metadata pages and unused dirty pages are included in this value. Pages may not be physically resident if they correspond to demand-zeroed virtual memory that has not yet been touched. This value is a maximum rather than a precise value and is a multiple of the page size. The value is greater than the stats.active.|
162162
| RETAINED | The amount retained by the virtual memory mappings of the operating system. This value does not include any returned mappings. This type of memory, usually de-committed, untouched, or purged. The value is associated with physical memory and is excluded from mapped memory statistics. |
163163
| METADATA | The total amount dedicated to metadata. This value contains the base allocations which are used for bootstrap-sensitive allocator metadata structures. Transparent huge pages usage is not included. |
164164

165165
## malloc_stats
166166

167-
The cumulative number of allocations requested or allocations returned for a running instance.
167+
The cumulative statistics for allocations and deallocations for a running instance.
168168

169169
| Column Name | Description |
170170
| --------------------- | --------------------------------------------------- |
@@ -188,7 +188,7 @@ Description: This read-only variable returns `true` if jemalloc with profiling e
188188

189189
* The environment variable `MALLOC_CONF` is set to `prof:true`.
190190

191-
The following options are:
191+
Properties:
192192

193193
* Scope: Global
194194

@@ -200,7 +200,7 @@ The following options are:
200200

201201
Description: Enables jemalloc profiling. The variable requires [jemalloc_detected](#jemalloc_detected).
202202

203-
* Command Line: jemalloc_profiling[=(OFF|ON)]
203+
* Command Line: --jemalloc_profiling[=(OFF|ON)]
204204

205205
* Config File: Yes
206206

docs/yum-download-rpm.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following example downloads *Percona Server for MySQL* {{release}} release `
4949
```
5050

5151

52-
4. Install `jemalloc` with the following command, if needed:
52+
4. Install `jemalloc` with the following command, if needed. See [When to install jemalloc](#when-to-install-jemalloc) for guidance:
5353

5454
```{.bash data-prompt="$"}
5555
$ wget https://repo.percona.com/yum/release/8/RPMS/x86_64/jemalloc-3.6.0-1.el8.x86_64.rpm
@@ -69,4 +69,32 @@ The following example downloads *Percona Server for MySQL* {{release}} release `
6969

7070
!!! note
7171

72-
When installing packages manually, you must make sure to resolve all dependencies and install any missing packages yourself.
72+
When installing packages manually, you must make sure to resolve all dependencies and install any missing packages yourself.
73+
74+
## When to install jemalloc
75+
76+
`jemalloc` is an alternative memory allocator that can improve performance and reduce memory fragmentation in certain scenarios. Consider the following when deciding whether to install `jemalloc`:
77+
78+
### Install jemalloc when:
79+
80+
* You have high-concurrency workloads with many threads
81+
82+
* You experience memory fragmentation issues that impact performance
83+
84+
* You run multi-threaded applications that perform frequent memory allocation and deallocation
85+
86+
* You want to use [memory profiling features](jemalloc-profiling.md) to investigate memory-related issues.
87+
88+
* You observe performance degradation related to memory allocation in your current setup
89+
90+
### Do not install jemalloc when:
91+
92+
* Your current memory allocator (typically glibc malloc) performs adequately for your workload
93+
94+
* You have single-threaded or low-concurrency workloads where jemalloc's benefits are minimal
95+
96+
* You encounter compatibility issues with jemalloc in your environment
97+
98+
* You need to debug memory issues that may be complicated by using an alternative allocator
99+
100+
* Your system is already optimized and stable with the default memory allocator

0 commit comments

Comments
 (0)