-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
zstd: don't call zstd_mempool_reap if there are no buffers #16302
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cc @behlendorf |
allanjude
approved these changes
Jun 27, 2024
tonyhutter
approved these changes
Jul 12, 2024
Just noticed a minor checkstyle error:
Would you mind updating your commit message? |
zfs_zstd_cache_reap_now is issued every second. zstd_mempool_reap checks for both pool existence and buffer count, but that's still 2 func calls which are trivially avoidable. With clang it even avoids pushing the stack pointer (but still suffers the mispredict due to a forward jump, not modified in case someone is using zstd): <+0>: cmpq $0x0,0x0(%rip) # <zfs_zstd_cache_reap_now+8> <+8>: je 0x217de4 <zfs_zstd_cache_reap_now+36> <+10>: push %rbp <+11>: mov %rsp,%rbp <+14>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+21> <+21>: call 0x217df0 <zstd_mempool_reap> <+26>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+33> <+33>: pop %rbp <+34>: jmp 0x217df0 <zstd_mempool_reap> <+36>: ret Preferably the call would not be made to begin with if zstd is not used, but this retains all the logic confined to zstd code. Sponsored by: Rubicon Communications, LLC ("Netgate") Signed-off-by: Mateusz Guzik <[email protected]>
calccrypto
pushed a commit
to hpc/zfs
that referenced
this pull request
Jul 17, 2024
…6302) zfs_zstd_cache_reap_now is issued every second. zstd_mempool_reap checks for both pool existence and buffer count, but that's still 2 func calls which are trivially avoidable. With clang it even avoids pushing the stack pointer (but still suffers the mispredict due to a forward jump, not modified in case someone is using zstd): <+0>: cmpq $0x0,0x0(%rip) # <zfs_zstd_cache_reap_now+8> <+8>: je 0x217de4 <zfs_zstd_cache_reap_now+36> <+10>: push %rbp <+11>: mov %rsp,%rbp <+14>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+21> <+21>: call 0x217df0 <zstd_mempool_reap> <+26>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+33> <+33>: pop %rbp <+34>: jmp 0x217df0 <zstd_mempool_reap> <+36>: ret Preferably the call would not be made to begin with if zstd is not used, but this retains all the logic confined to zstd code. Sponsored by: Rubicon Communications, LLC ("Netgate") Signed-off-by: Mateusz Guzik <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Tony Hutter <[email protected]>
lundman
pushed a commit
to openzfsonwindows/openzfs
that referenced
this pull request
Sep 4, 2024
…6302) zfs_zstd_cache_reap_now is issued every second. zstd_mempool_reap checks for both pool existence and buffer count, but that's still 2 func calls which are trivially avoidable. With clang it even avoids pushing the stack pointer (but still suffers the mispredict due to a forward jump, not modified in case someone is using zstd): <+0>: cmpq $0x0,0x0(%rip) # <zfs_zstd_cache_reap_now+8> <+8>: je 0x217de4 <zfs_zstd_cache_reap_now+36> <+10>: push %rbp <+11>: mov %rsp,%rbp <+14>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+21> <+21>: call 0x217df0 <zstd_mempool_reap> <+26>: mov 0x0(%rip),%rdi # <zfs_zstd_cache_reap_now+33> <+33>: pop %rbp <+34>: jmp 0x217df0 <zstd_mempool_reap> <+36>: ret Preferably the call would not be made to begin with if zstd is not used, but this retains all the logic confined to zstd code. Sponsored by: Rubicon Communications, LLC ("Netgate") Signed-off-by: Mateusz Guzik <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Tony Hutter <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
zfs_zstd_cache_reap_now is issued every second.
zstd_mempool_reap checks for both pool existence and buffer count, but that's still 2 func calls which are trivially avoidable.
With clang it even avoids pushing the stack pointer:
Preferably the call would not be made to begin with if zstd is not used, but this retains all the logic confined to zstd code.
Sponsored by: Rubicon Communications, LLC ("Netgate")
Signed-off-by: Mateusz Guzik [email protected]
Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.