News for hackers. Stuff that matters.
Re:55 GiB/s FizzBuzz (2021) by londons_explore on Monday July 03, 2023 @06:14AM (#36570948)
The most impressive thing to me is that Linux allows data piped from one program to another to stay entirely in L2 cache and not hit main memory.

To me, that is amazing systems architectural design - so many different parts of a regular linux kernel all working together to let this fastpath happen.

Would such a thing be possible on Mac OSX's Mach ports or Windows's Named Pipes?

Re:55 GiB/s FizzBuzz (2021) by zeusk on Monday July 03, 2023 @06:38AM (#36571087)
If a CPU's caches are physically tagged and both process's page tables share the same backing physical page then the CPU will let the cache contents be used by either process as long as the OS doesn't explicitly flush/invalidate cache on context switch.
Re:55 GiB/s FizzBuzz (2021) by twoodfin on Monday July 03, 2023 @08:50AM (#36572177)
The major cost of two processes coordinating shared data over two threads is TLB invalidation on a context switch.

I assume this is what the author meant by “page table contention” as a bottleneck: Without TLB invalidation there would be no need for either process/thread to ever touch page tables in a scenario like this.

Re:55 GiB/s FizzBuzz (2021) by zeusk on Monday July 03, 2023 @08:58AM (#36572261)
It's unrelated to TLB; page table contention is related to associative caches where you can have two distinct addresses map to the same cache set and cause false cache miss or exhaust the cache set and cause repeated fill from memory.

TLB has to be flushed for process context switch on x86 regardless of Windows/Linux - but modern systems typically allow it to be selectively flushed (the system can elect to not flush tlb for the shared mappings that exist in both processes).

TLB miss vs Cache miss are an order of magnitude apart, and multiple orders if the corresponding pte itself is resident in dcache.

Re:55 GiB/s FizzBuzz (2021) by twoodfin on Monday July 03, 2023 @09:09AM (#36572374)
TLB has to be flushed for process context switch on x86 regardless of Windows/Linux - but modern systems typically allow it to be selectively flushed (the system can elect to not flush tlb for the shared mappings that exist in both processes).

What’s the mechanism for this? AFAIK one of the main motivations for the recent heated discussions on PostgreSQL adopting a threaded model would be eliminating TLB flushes in high-context-switch environments. Can Linux already preserve their (massive) shared mappings?

Re:55 GiB/s FizzBuzz (2021) by zeusk on Monday July 03, 2023 @09:30AM (#36572616)
ASID (Address Space ID) or as Intel calls it PCID (Process Context ID).

The OS juggles these based on what processes are resident on CPU and the various active mappings then uses INVPCID[0] during a context switch.

[0]: https://www.felixcloutier.com/x86/invpcid

Re:55 GiB/s FizzBuzz (2021) by SkipperCat on Monday July 03, 2023 @07:17AM (#36571358)
This is one of the many reasons that the entire HFT world runs on Linux.
Re:55 GiB/s FizzBuzz (2021) by amatic on Monday July 03, 2023 @09:19AM (#36572486)
Do they also use assembler in HFT?
Re:55 GiB/s FizzBuzz (2021) by defrost on Monday July 03, 2023 @09:26AM (#36572560)
Custom hardware, custom drivers, custom UDP stack.

It's not just the algo's it's very much the latency.

Re:55 GiB/s FizzBuzz (2021) by SkipperCat on Monday July 03, 2023 @10:22AM (#36573310)
For speed, its mostly FPGAs. You can put them directly at the demarc between you and the exchange.
Re:55 GiB/s FizzBuzz (2021) by IshKebab on Monday July 03, 2023 @01:55PM (#36576522)
They use custom ASICs too.
Re:55 GiB/s FizzBuzz (2021) by idlewords on Monday July 03, 2023 @10:58AM (#36573837)

  if(((i%3)||(i%5))== 0)
     buy_0_day_to_expiry_options()
Re:55 GiB/s FizzBuzz (2021) by SkipperCat on Monday July 03, 2023 @11:33AM (#36574372)
I may backtest this over the weekend just in case it has some alpha :)
Re:55 GiB/s FizzBuzz (2021) by kinghajj on Monday July 03, 2023 @03:14PM (#36577544)
But 0dte options on SPX are available for each day of the week now!

    if (is_trading_day())
        buy_0_day_to_expiry_options()
Re:55 GiB/s FizzBuzz (2021) by smabie on Monday July 03, 2023 @11:27AM (#36574273)
I've heard of some windows HFT systems, tho I'm sure that's suboptimal.