Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8037

Teaching and learning resources • Re: Advent of Code 2024

$
0
0
Shy has been shyly meowing that the code should run three times faster. Scratchy claims that's not enough. Fortunately, the kittens are litter mates so never get into a fight.
Scratch moved the allocation for mem outside the rungates routine and obtained.

Code:

$ ./go24 # Pi 4B 1500 MHzAdvent of Code 2024 Day 24 Crossed Wires (GOMAXPROCS=4)Part 1 The z wires output 61495910098126Part 2 Swap wires css,cwt,gdd,jmv,pqt,z05,z09,z37Total execution time 4.693544958 seconds.
This saves another half second of runtime. Purr claimed the savings were not worth the code complexity and tried to back the changes out while Shy shyly eyed the mouse. This was about to precipitate the first cat fight between black kittens, but I stepped in saying let the market decide and made this post.
The new code is much more effective on the Xeon server.

Code:

Dual Xeon E5-2620 v3Cores     Threads    Sockets    Seconds 12         12          2        0.801 12         24          2        0.889  6          6          1        1.005  6         12          1        1.085  1          2          1        3.514  1          1          1        4.497
Now there is a speedup rather than slowdown when running on both sockets. That is consistent with Purr's claim that heap allocations are slower when a program crosses multiple NUMA zones. In my opinion the speedup can be explained more simply. Fewer memory allocations also mean less time spent collecting garbage.

Statistics: Posted by ejolson — Fri May 02, 2025 12:52 am



Viewing all articles
Browse latest Browse all 8037

Trending Articles