Bug #80087
closedOSD: unexpected high memory usage for OSDs in EC pools where "alloc_ec_optimizations" is true
0%
Description
Recently, when conducting RGW stress tests, we found some OSDs in the EC data pool where "allow_ec_optimizations" is configured to true to enable fast ec occupied 10+GB while the "osd_memory_target" is the default 4GB.
The above memory consumption persisted even after the stress workload stopped, and almost all the memory occupied was accounted as "ceph_bluestore_pricache_mapped_bytes"

The dumped mempools:
{
"mempool": {
"by_pool": {
"bloom_filter": {
"items": 0,
"bytes": 0
},
"bluestore_alloc": {
"items": 31482035,
"bytes": 312277096
},
"bluestore_cache_data": {
"items": 18,
"bytes": 1414599
},
"bluestore_cache_onode": {
"items": 10462,
"bytes": 7676736
},
"bluestore_cache_meta": {
"items": 2240021,
"bytes": 15525124
},
"bluestore_cache_other": {
"items": 1702399,
"bytes": 13627472
},
"bluestore_cache_buffer": {
"items": 37,
"bytes": 896
},
"bluestore_extent": {
"items": 99179,
"bytes": 4760592
},
"bluestore_blob": {
"items": 99179,
"bytes": 11901480
},
"bluestore_shared_blob": {
"items": 0,
"bytes": 0
},
"bluestore_inline_bl": {
"items": 9097,
"bytes": 13823008
},
"bluestore_fsck": {
"items": 0,
"bytes": 0
},
"bluestore_txc": {
"items": 1,
"bytes": 768
},
"bluestore_writing_deferred": {
"items": 55,
"bytes": 50388
},
"bluestore_writing": {
"items": 5,
"bytes": 160
},
"bluefs": {
"items": 6419,
"bytes": 465160
},
"bluefs_file_reader": {
"items": 1980,
"bytes": 480546560
},
"bluefs_file_writer": {
"items": 4,
"bytes": 800
},
"buffer_anon": {
"items": 53523,
"bytes": 16241191
},
"buffer_meta": {
"items": 1136,
"bytes": 99968
},
"osd": {
"items": 78,
"bytes": 938496
},
"osd_mapbl": {
"items": 0,
"bytes": 0
},
"osd_pglog": {
"items": 624690,
"bytes": 192145423
},
"osdmap": {
"items": 16817,
"bytes": 674944
},
"osdmap_mapping": {
"items": 0,
"bytes": 0
},
"pgmap": {
"items": 0,
"bytes": 0
},
"mds_co": {
"items": 0,
"bytes": 0
},
"ec_extent_cache": {
"items": 35,
"bytes": 10231808
},
"unittest_1": {
"items": 0,
"bytes": 0
},
"unittest_2": {
"items": 0,
"bytes": 0
}
},
"total": {
"items": 36347170,
"bytes": 1082402669
}
}
}
OSD heap stats:
osd.66 tcmalloc heap stats:------------------------------------------------ MALLOC: 11438463672 (10908.6 MiB) Bytes in use by application MALLOC: + 0 ( 0.0 MiB) Bytes in page heap freelist MALLOC: + 182729040 ( 174.3 MiB) Bytes in central cache freelist MALLOC: + 419840 ( 0.4 MiB) Bytes in transfer cache freelist MALLOC: + 112485368 ( 107.3 MiB) Bytes in thread cache freelists MALLOC: + 76414976 ( 72.9 MiB) Bytes in malloc metadata MALLOC: ------------ MALLOC: = 11810512896 (11263.4 MiB) Actual memory used (physical + swap) MALLOC: + 940711936 ( 897.1 MiB) Bytes released to OS (aka unmapped) MALLOC: ------------ MALLOC: = 12751224832 (12160.5 MiB) Virtual address space used MALLOC: MALLOC: 1233858 Spans in use MALLOC: 37 Thread heaps in use MALLOC: 8192 Tcmalloc page size ------------------------------------------------ Call ReleaseFreeMemory() to release freelist memory to the OS (via madvise()). Bytes released to the OS take up virtual address space but no physical memory.
Files
RZ Updated by Radoslaw Zarzynski 3 months ago
- Assignee set to Alex Ainscow
Hi @Alex Ainscow, would you mind taking a look?
AA Updated by Alex Ainscow 3 months ago
Not much to go on here, or indications that there is a real bug.
ceph_bluestore_pricache_mapped_bytes essentially tracks memory used by tcmalloc. The fact that your memory was stable during the stress test suggests that this is not a memory leak.
The memory target that was set is a target, but it is not guaranteed and if the OSD process needs more memory, then it will consume it.
I ran some memory consumption tests shortly after Tentacle release and found that FastEC and Classic EC have broadly similar memory requirements.
I need more information to investigate this further:
1. A comparison to Classic EC, which shows fast EC is slower.
2. Much more detail about what the "Stress test" is - how many objects, sizes, etc...
3. Much more information about the configuration - Pools, PGs, RGW, etc...
4. Details instructions for how to recreate the issue.
AA Updated by Alex Ainscow 3 months ago
- Status changed from New to Need More Info
XX Updated by Xuehan Xu 3 months ago
- File clipboard-202609031010-dplgs.png clipboard-202609031010-dplgs.png added
- File clipboard-202609031016-ipeca.png clipboard-202609031016-ipeca.png added
ceph_bluestore_pricache_mapped_bytes essentially tracks memory used by tcmalloc. The fact that your memory was stable during the stress test suggests that this is not a memory leak.
Sorry, the graph was taken during the time when there was no stress test going on. The following picture is the dynamic memory usage graph across the whole data prefilling phase. As you can see, the data pool OSDs' memory usage kept growing and stayed there even after the stress was stopped.
One thing to note that, it seemed that, the memory usage growth mainly happened during the data prefilling phase, and seemed to come to steady during the real stress test phase.
1. A comparison to Classic EC, which shows fast EC is slower.
2. Much more detail about what the "Stress test" is - how many objects, sizes, etc...
3. Much more information about the configuration - Pools, PGs, RGW, etc...
4. Details instructions for how to recreate the issue.
Compared with classic EC, fast EC was much faster when the object was smaller than the stripe size.
We used the following cosbench configuration to prefill the cluster to the point that each OSD possessed about 150M objects, during which the massive memory usage growth happened.
<?xml version="1.0" encoding="UTF-8"?>
<workload name="data_filling" description="filling 4KB objects, totally occupying 40TB">
<storage type="s3" config="accesskey=VH4SI1P1V3I0NXQ1LPA0;secretkey=63PxBScbcBYQ2TOIun4oUfOVPpTRW4VZyuqEbfft;endpoint=http://10.57.81.17:7480;path_style=true" />
<workflow>
<workstage name="create-bucket">
<work type="init" workers="1" config="cprefix=data-filling;containers=r(1,1)" />
</workstage>
<workstage name="main">
<work name="main" workers="500" runtime="604800">
<operation type="write" ratio="100" config="cprefix=data-filling;containers=u(1,1);objects=u(1000000000,2000000000);oprefix=xxh_;sizes=c(4)KB" />
</work>
</workstage>
</workflow>
</workload>
The test cluster has three full-SSD machines each of which contains 12 full-SSD OSDs and three SSD-HDD hybrid machines each of which contains 2 SSDs and 12 HDDs, the SSD-HDD OSD shares the two SSDs on the machine.
We used 1 RGW instance for the stress test, and configured the data pool with 256 PGs and 6:3 erasure-profile. The following is the pool and erasure-code-profile configuration:
[root@cephqa01 xuxuehan]# ceph osd pool get default.rgw.buckets.data all size: 9 min_size: 7 pg_num: 256 pgp_num: 256 crush_rule: default-hdd-ec-rule hashpspool: true allow_ec_overwrites: false nodelete: false nopgchange: false nosizechange: false write_fadvise_dontneed: false noscrub: false nodeep-scrub: false use_gmt_hitset: 1 erasure_code_profile: ec63 fast_read: 0 pg_autoscale_mode: on eio: false bulk: false allow_ec_optimizations: false
[root@cephqa01 xuxuehan]# ceph osd erasure-code-profile get ec63 crush-device-class=hdd crush-failure-domain=osd crush-num-failure-domains=0 crush-osds-per-failure-domain=0 crush-root=default k=6 m=3 plugin=isa technique=reed_sol_van
LF Updated by Laura Flores 3 months ago
Bump up (cc @aainscow)
AA Updated by Alex Ainscow 3 months ago
Apologies - I didn't ask my first question correctly.
My main question is how does memory consumption compare to classic EC. We do expect fast EC to use a little more memory, but not an order of magnitude more.
The ramp-up during pre-fill is expected on all configurations - so its a question of whether this is better or worse than classic EC.
XX Updated by Xuehan Xu 3 months ago
Alex Ainscow wrote in #note-10:
Apologies - I didn't ask my first question correctly.
My main question is how does memory consumption compare to classic EC. We do expect fast EC to use a little more memory, but not an order of magnitude more.
The ramp-up during pre-fill is expected on all configurations - so its a question of whether this is better or worse than classic EC.
The following is the memory usage we observed during the pre-fill phase in a classic EC case, as you can see, with the classic EC, the memory usage was kept below 4GB which was the value of osd_memory_target:
AA Updated by Alex Ainscow 3 months ago
- Assignee changed from Alex Ainscow to Lee Sanders
We have managed to recreate the problem. We are looking into it further.
LS Updated by Lee Sanders 3 months ago
I think I've been able to recreate this problem with the following config.
Single node system
8 OSDS
4+2 Erasure Code - allow_ec_optimizations on
v20.2.3 tentacle
4 RGW gateways
4 instances of Elbencho creating 4k objects (prefill)
ceph -s[ceph: root@o01 /]# ceph -s
cluster:
id: ea8a7014-b017-11f1-a5c3-3cfdfed26a80
health: HEALTH_WARN
mon o01 is low on available space
noscrub,nodeep-scrub flag(s) set
services:
mon: 1 daemons, quorum o01 (age 23h) [leader: o01]
mgr: o01.eotciy(active, since 23h), standbys: o01.iqxjqo
osd: 8 osds: 8 up (since 23h), 8 in (since 23h)
flags noscrub,nodeep-scrub,noautoscale
rgw: 4 daemons active (1 hosts, 1 zones)
data:
pools: 7 pools, 225 pgs
objects: 695.22M objects, 2.6 TiB
usage: 9.8 TiB used, 48 TiB / 58 TiB avail
pgs: 225 active+clean
io:
client: 47 MiB/s rd, 48 MiB/s wr, 63.61k op/s rd, 97.52k op/s wr

After about 7 hours of running each OSD was using about 11-12gb.
I left the system overnight running and after about 22 hours several OSDS are using 30-35Gbyte of memory
LF Updated by Laura Flores 3 months ago
- Status changed from Need More Info to In Progress
VU Updated by Vikhyat Umrao 3 months ago ยท Edited
Lee Sanders wrote in #note-13:
I think I've been able to recreate this problem with the following config.
After about 7 hours of running each OSD was using about 11-12gb.
I left the system overnight running and after about 22 hours several OSDS are using 30-35Gbyte of memory
Good work, Lee! it is always much better path to RCA when we have consistent reproducer in house!
AA Updated by Alex Ainscow 2 months ago
- Pull request ID set to 72069
AA Updated by Alex Ainscow 2 months ago
- Related to Bug #80858: OSD: ECOmapJournal retains empty per-object nodes until interval change, growing memory with omap writes to many objects added
LF Updated by Laura Flores 2 months ago
Radek is leaving a review on the PR.
RZ Updated by Radoslaw Zarzynski about 2 months ago
Approved, sent to QA.
UB Updated by Upkeep Bot about 2 months ago
- Status changed from In Progress to Resolved
- Merge Commit set to 8b195b8edebf6954fd0b2fa7e8724b6ede01f84b
- Fixed In set to v21.3.0-4344-g8b195b8ede
- Upkeep Timestamp set to 2026-10-13T08:47:17+00:00