Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smallfile improvement in glusterfs #2771

Closed
mohit84 opened this issue Sep 7, 2021 · 1 comment
Closed

Smallfile improvement in glusterfs #2771

mohit84 opened this issue Sep 7, 2021 · 1 comment
Assignees
Milestone

Comments

@mohit84
Copy link
Contributor

mohit84 commented Sep 7, 2021

As we know, we always tried to improve Smallfile performance in glusterfs.After doing a long duration testing we have found memory allocation is a big area that affects smallfile performance significantly in glusterfs. As we know before merged the patch #2675, gluster uses own thread based pool to allocate/deallocate memory blocks.In testing we observed it performs well as compare to glibc thread based pool but it does not perform well as compare to tcmalloc pool so we have decided to move to tcmalloc as a default option instead of using glibc pool.

I have executed a smallfile perf test case for 4.8M files 64K (more than 20 times on usual day operation) on latest devel branch.I have setup 12x3(nvme) volume after configure 4 event threads on 12 physical machines, there is no other configurable option i have enabled.

Hardware details:
12 physical machines (6 client, 6 servers)
Every machine is having 64 CPU 32G RAM, 10g NIC
Run smallfile tool to run operations and total number of files are 4.8M

Below is the data 

   

FOPS Before #2675(mempool is enabled) After #2675(disable mempool) Enable tcmalloc(on top #2675)
create 14164.8 12064.8(-14.83) 16265.5(14.83)
ls-l 235044 211641(-9.96) 266195(13.25)
chmod 25391.9 23191(-8.67) 26516(4.43)
stat 29976.7 30762.5(2.62) 30334.9(1.19)
read 26140.7 23930.2(-8.46) 30394.4(16.27)
append 12853.7 12654(-1.55) 13384.9(4.13)
mkdir 2628.81 2488.85(-5.32) 2934.45(11.63)
rmdir 2436.01 2250.12(-7.63) 2654.48(8.97)
cleanup 6556.44 5439.39(-17.04) 8992.76(37.16)

During running a test case i have observed iobuf_pool lock has significant contention so i have tried to replace iobuf_pool with thread based pool(mempool). Iobuf_pool lock is process based lock so it is highly contended while we used thread based mempool we were getting performance improvement.After running multiple test cases for long duration with multiple options(iobuf_with malloc, iobuf_with_thread based pool) we have decided for the time being it is a good idea to move on standard malloc for iobuf also while a requested buffer size is less than 128k otherwise use current Iobuf pool allocation to allocate the memory.

Below is the data after using tcmalloc pool for buffer less than 128k

FOPS Before #2675(mempool is enabled) After #2675(disable mempool) Enable tcmalloc(on top of #2675) Enable tcmalloc with iobuf_128Kmalloc(on top of #2675)
create 14164.8 12064.8(-14.83) 16265.5(14.83)) 16703.8(17.92)
ls-l 235044 211641(-9.96) 266195(13.25) 276855(17.79)
chmod 25391.9 23191(-8.67) 26516(4.43) 26812.1(5.59)
stat 29976.7 30762.5(2.62) 30334.9(1.19) 30391.2(1.38)
read 26140.7 23930.2(-8.46) 30394.4(16.27) 33075.2(26.53)
append 12853.7 12654(-1.55) 13384.9(4.13) 13474.5(4.83)
mkdir 2628.81 2488.85(-5.32) 2934.45(11.63) 3568.03(35.73)
rmdir 2436.01 2250.12(-7.63) 2654.48(8.97) 3396.19(39.42)
cleanup 6556.44 5439.39(-17.04) 8992.76(37.16) 9286.83(41.64)

Along with iobuf_patch there is one minor optimization we did in memory allocation, after call gf_calloc/gf_malloc/gf_free we do take a lock for memory accounting in xlator, we did optimize it further to delete some of the variable and convert some variable to atomic to avoid a lock

Below is the result

FOPS Before #2675(mempool is enabled) After #2675(disable mempool) Enable tcmalloc(on top of #2675) Enable tcmalloc with iobuf_128Kmalloc(on top of #2675) Enable tcmalloc with 128KMalloc with lockfree mem_accounting(on top of #2675)
create 14164.8 12064.8(-14.83) 16265.5(14.83) 16703.8(17.92) 16884(19.20)
ls-l 235044 211641(-9.96) 266195(13.25) 276855(17.79) 285055(21.28)
chmod 25391.9 23191(-8.67) 26516(4.43) 26812.1(5.59) 26900.6(5.94)
stat 29976.7 30762.5(2.62) 30334.9(1.19) 30391.2(1.38) 30394.1(1.39)
read 26140.7 23930.2(-8.46) 30394.4(16.27) 33075.2(26.53) 33275.3(27.29)
append 12853.7 12654(-1.55) 13384.9(4.13) 13474.5(4.83) 13627.5(6.02)
mkdir 2628.81 2488.85(-5.32) 2934.45(11.63) 3568.03(35.73) 3685.53(40.20)
rmdir 2436.01 2250.12(-7.63) 2654.48(8.97) 3396.19(39.42) 3472.65(42.55)
cleanup 6556.44 5439.39(-17.04) 8992.76(37.16) 9286.83(41.64) 9834.65(50.00)

During tcmalloc testing i have found one minor challenge with tcmalloc is it consumes more than 20% memory as compare to glibc (ptmalloc) while IO is running for long duration because it happened due to the the design of tcmalloc. After read the tcmalloc documentation i have found it provides some api’s(ReleaseMemroy) to return the excess memory to the system. In my case the client(fuse) consume at max 850M(tcmalloc) vs 700M(glibc malloc) and brick consumes 150M(tcmalloc) vs 125M(glibc malloc) so i it not much high.Later we can call tcmalloc functions to cleanup the excess memory.

A big thanks to Xavi/Yaniv for giving a guidance to make it successful.

@mohit84 mohit84 self-assigned this Sep 7, 2021
@msaju msaju added this to the Gluster X milestone Sep 7, 2021
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 7, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 7, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 8, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 8, 2021
Fixes: gluster#2771
Change-Id: I510a9609452c4960b51e69643823d8ec28a65f08
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 8, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 8, 2021
Fixes: gluster#2771
Change-Id: I510a9609452c4960b51e69643823d8ec28a65f08
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 13, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
…n equal 128KB

During smallfile testing we have observed the performance
has been improved significantly in case while iobuf use standard
allocation api to allocate buffer while requested page_size is less
than or equal to 128KB.The performance data is available at the
github issue gluster#2771

Fixes: gluster#2771
Change-Id: I0cf1509658af7db712d62eac3c5cc6c84e1bc591
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
…n equal 128KB

    During smallfile testing we have observed the performance
    has been improved significantly in case while iobuf use standard
    allocation api to allocate buffer while requested page_size is less
    than or equal to 128KB.The performance data is available at the
    github issue gluster#2771

    Fixes: gluster#2771
    Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: Ib51e54e10c6d7334962e41c8f277a78b676fbe5a
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Fixes: gluster#2771
Change-Id: I29256db870185d521d9b9adc2b7fd66646ed1c56
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
…n equal 128KB

    During smallfile testing we have observed the performance
    has been improved significantly in case while iobuf use standard
    allocation api to allocate buffer while requested page_size is less
    than or equal to 128KB.The performance data is available at the
    github issue gluster#2771

    Fixes: gluster#2771
    Change-Id: Ib51e54e10c6d7334962e41c8f277a78b676fbe5a
    Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: I4c9ec1d2f4b8df626808fe81b7392314dc8a0e05
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
The data is already available on github issue(gluster#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit that referenced this issue Sep 15, 2021
…2787)

The data is already available on github issue(#2771)
specific to getting improvement after enable tcmalloc and
disable mempool so enable tcmalloc and disable mempool
as a default option.

Updates: #2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
…n equal 128KB

During smallfile testing we have observed the performance
has been improved significantly in case while iobuf use standard
allocation api to allocate buffer while requested page_size is less
than or equal to 128KB.The performance data is available at the
github issue gluster#2771

Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 15, 2021
…n equal 128KB

During smallfile testing we have observed the performance
has been improved significantly in case while iobuf use standard
allocation api to allocate buffer while requested page_size is less
than or equal to 128KB.The performance data is available at the
github issue gluster#2771

Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 16, 2021
…n equal 128KB

During smallfile testing we have observed the performance
has been improved significantly in case while iobuf use standard
allocation api to allocate buffer while requested page_size is less
than or equal to 128KB.The performance data is available at the
github issue gluster#2771

Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 16, 2021
Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 16, 2021
Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
    Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
    Updates: gluster#2771
    Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: I2c598a2a3995d9300584ce3bcab4558aafc7e74d
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
Change-Id: I2c598a2a3995d9300584ce3bcab4558aafc7e74d
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
Change-Id: I2c598a2a3995d9300584ce3bcab4558aafc7e74d
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
Change-Id: I2c598a2a3995d9300584ce3bcab4558aafc7e74d
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit that referenced this issue Sep 17, 2021
…n equal to 128KB (#2792)

* iobuf: Call standard allocation api in iobuf if page_size is less than equal 128KB

During smallfile testing we have observed the performance
has been improved significantly in case while iobuf use standard
allocation api to allocate buffer while requested page_size is less
than or equal to 128KB.The performance data is available at the
github issue #2771

Change-Id: I9aebb19e15640aedea8c78efb366703dbdebb5fd
Updates: #2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
The __gf_(c|m)alloc and __gf_free memory allocation api calls
gf_mem_set_acct_info function to save memory accounting
on xlator and to update the record it takes lock.During
testing we have observed the mem_acct mutex has contention.

Solution: To avoid contention make it lock free and the data
          is available at github issue gluster#2771

Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: I9ab2a2e5b7d64e98aad92cecaa3bebc914e0a55b
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 17, 2021
The __gf_(c|m)alloc and __gf_free memory allocation api calls
gf_mem_set_acct_info function to save memory accounting
on xlator and to update the record it takes lock.During
testing we have observed the mem_acct mutex has contention.

Solution: To avoid contention make it lock free and the data
          is available at github issue gluster#2771

Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Credits: Xavi Hernandez <xhernandez@redhat.com>
Change-Id: I9ab2a2e5b7d64e98aad92cecaa3bebc914e0a55b
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 22, 2021
Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: Ia5db076908662453e93d2bb4832ef5060be0c1cc
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 22, 2021
Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: I3352c97a1b4e8b538b1e6e97e9de3b3e674d2223
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 23, 2021
Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: Ie5869e8ef4815d36f065d6f18aa78ba6507d65be
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 23, 2021
Updates gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: Ie5869e8ef4815d36f065d6f18aa78ba6507d65be
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 23, 2021
Updates gluster#2771
Signed-off-by: Mohit Agrawal moagrawa@redhat.com

Change-Id: I4ce44366645151e89181907591ab65373a89f91c
mohit84 added a commit that referenced this issue Sep 24, 2021
* mem_acct: Make mem_accounting lock free

The __gf_(c|m)alloc and __gf_free memory allocation api calls
gf_mem_set_acct_info function to save memory accounting
on xlator and to update the record it takes lock.During
testing we have observed the mem_acct mutex has contention.

Solution: To avoid contention make it lock free and the data
          is available at github issue #2771

Updates #2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Credits: Xavi Hernandez <xhernandez@redhat.com>
Change-Id: I9ab2a2e5b7d64e98aad92cecaa3bebc914e0a55b
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 28, 2021
The size variable does not necessary to debug mem leak from
mem_acct so move the variable for debug build.

Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
mohit84 added a commit to mohit84/glusterfs that referenced this issue Sep 30, 2021
Updates: gluster#2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
xhernandez pushed a commit that referenced this issue Oct 5, 2021
The size variable does not necessary to debug mem leak from
mem_acct so move the variable for debug build.

Updates: #2771
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
@mohit84
Copy link
Contributor Author

mohit84 commented Oct 26, 2021

All the required patches are merged so i am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants