3 ms·
I'll second looking at the assembly code. I had a similar problem a few years ago and an assembly expert told us that we were moving data in and out of the cach
by maxxxxx 9y ago
I'll second looking at the assembly code. I had a similar problem a few years ago and an assembly expert told us that we were moving data in and out of the cache all the time instead of leaving it there. We had to change the way we looped through arrays and got a huge improvement. this could be wrong but I would also guess that the Swift optimizer is not as good as the ones C++ has mainly for the reason that it's newer.
- CyberDildonics 9y agoYou don't need to look at assembly to avoid cache misses, you just need to understand what the language is doing under the hood in a general sense, then make sure you access memory in a way that it can be prefetched. My guess is that it is either the program being written slightly differently or that swift is doing some sort of indirection under the hood.
- maxxxxx 9y ago"you just need to understand what the language is doing under the hood in a general sense" Isn't the best to find out to look at the assembly? How else can you know what the compiler and optimizer are doing?
- CyberDildonics 9y agoNo, understanding what the language is doing is not the same as looking at assembly or even understanding what the optimizer is doing. If swift is creating some variables on the heap and/or creating virtual tables for inheritance (I don't know much about it) then you don't need to look at the assembly to know that you are creating indirection or doing too many heap allocations.