Investigating Split Locks on x86-64
chipsandcheese.com
Investigating Split Locks on x86-64
1–10 of 30 posts
Re: Investigating Split Locks on x86-64
#2> Games have apparently been using split locks for quite a while, and have not created issues even on AMD’s Zen 2 and Zen 5.
For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines....
Re: Investigating Split Locks on x86-64
#3Cool investigation. This part perplexes me, though: > Games have apparently been using split locks for quite a while, and have not created issues even on AMD’s Zen 2 and Zen 5. For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines....
I assume they force packed their structure and it's poorly aligned, but x86 doesn't fault on unaligned access and Windows doesn't detect and punish split locks, so while you probably would get better performance with proper alignment, it might not be a meaningful improvement on the majority of the machines running the program.
Re: Investigating Split Locks on x86-64
#4Cool investigation. This part perplexes me, though: > Games have apparently been using split locks for quite a while, and have not created issues even on AMD’s Zen 2 and Zen 5. For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines....
> For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines.... I assume they force packed their structure and it's poorly aligned, but x86 doesn't fault on unaligned access and Windows doesn't detect and punish split locks, so while you probably would get better performance with proper alignment, it might not be a meaningf…
Re: Investigating Split Locks on x86-64
#5Earlier quoted context omitted.
> For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines.... I assume they force packed their structure and it's poorly aligned, but x86 doesn't fault on unaligned access and Windows doesn't detect and punish split locks, so while you probably would get better performance with proper alignment, it might not be a meaningf…
Ah, that's a great hypothesis. I wonder, then, how it works with x86 emulation on ARM. IIRC, atomic ops on ARM fault if the address isn't naturally aligned... but I guess the runtime could intercept that and handle it slowly.
Re: Investigating Split Locks on x86-64
#6Earlier quoted context omitted.
Ah, that's a great hypothesis. I wonder, then, how it works with x86 emulation on ARM. IIRC, atomic ops on ARM fault if the address isn't naturally aligned... but I guess the runtime could intercept that and handle it slowly.
An emulated x86 atomic instruction wouldn’t need to use atomic instructions on ARM.
Re: Investigating Split Locks on x86-64
#7Earlier quoted context omitted.
An emulated x86 atomic instruction wouldn’t need to use atomic instructions on ARM.
Why not?
As an example, what about a divide instruction. A machine without an FPU can emulate a machine that has one. It will legitimately have to run hundreds/thousands of instructions to emulate a single divide instruction, it will certainly take longer.
Thats OK, just means the emulation is slower doing that than something like add that the host has a native instruction for. In ‘emulator time’ you still only ran one instruction. That world is still consistent.
Re: Investigating Split Locks on x86-64
#8Earlier quoted context omitted.
> For the life of me I don't understand why you'd ever want to do an atomic operation that's not naturally aligned, let alone one split across cache lines.... I assume they force packed their structure and it's poorly aligned, but x86 doesn't fault on unaligned access and Windows doesn't detect and punish split locks, so while you probably would get better performance with proper alignment, it might not be a meaningf…
Ah, that's a great hypothesis. I wonder, then, how it works with x86 emulation on ARM. IIRC, atomic ops on ARM fault if the address isn't naturally aligned... but I guess the runtime could intercept that and handle it slowly.
Re: Investigating Split Locks on x86-64
#9Earlier quoted context omitted.
Why not?
They don’t have to match. As an example, what about a divide instruction. A machine without an FPU can emulate a machine that has one. It will legitimately have to run hundreds/thousands of instructions to emulate a single divide instruction, it will certainly take longer. Thats OK, just means the emulation is slower doing that than something like add that the host has a native instruction for. In ‘emulator time’ you…
Re: Investigating Split Locks on x86-64
#10Frankly, I’m surprised split lock detection is enabled anywhere outside of multi-tenant clouds.