-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tcmalloc: improve malloc fast path codegen
Currently malloc fast path contains the following instruction related to Sampler address calculation that is unused on the fast path: 31241c: 64 48 8b 0c 25 00 00 mov %fs:0x0,%rcx 312423: 00 00 And then the slow path (sampling undo) is: 31248f: 48 8d 89 ec fc ff ff lea -0x314(%rcx),%rcx 312496: 48 01 41 28 add %rax,0x28(%rcx) With this change the excessive instruction is removed from the fast path, and the slow path becomes: 312346: 64 48 01 04 25 14 fd add %rax,%fs:0xfffffffffffffd14 31234d: ff ff So that's -2 instructions/-11 bytes. The only way to achieve this I found is by introducing an alias of the Sampler variable, such that compiler is not aware that it's an alias. name old cpu/op new cpu/op delta BM_new_sized_delete/1 4.16ns ± 1% 3.80ns ± 0% -8.56% (p=0.016 n=5+4) BM_new_sized_delete/8 4.18ns ± 2% 3.81ns ± 0% -8.89% (p=0.008 n=5+5) name old INSTRUCTIONS/op new INSTRUCTIONS/op delta BM_new_sized_delete/1 54.0 ± 0% 53.0 ± 0% -1.85% (p=0.029 n=4+4) BM_new_sized_delete/8 54.0 ± 0% 53.0 ± 0% -1.85% (p=0.008 n=5+5) PiperOrigin-RevId: 571310663 Change-Id: Ia99695a099eddbb8492cdc993057c011063728fb
- Loading branch information
1 parent
e239ffa
commit 60282bf
Showing
3 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
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
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
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