开发者

Reduced F# performance on x64 target?

Recently, I was surprised by the behavior of the F# compiler when using 开发者_StackOverflowx64 target compared to x86. The same application works with the following time on different targets:

x86:            68ms
Any CPU/x64:    160ms

For me this results are strange. The results differ by almost two-fold. I assumed that on 64-bit processor, 64-bit operating system the 64-bit application will work faster than 32-bit one.

So question is: What is wrong? Problem is in compiler or it's my fault somewhere?

Environment: Core 2 Duo and Windows 7 x64. F# application: FsYacc/FsLex language parser. .Net 4 Framework.


This can happen for programs that use a lot of pointer-heavy data structures, since a pointer is 8 bytes on 64-bit, whereas it's 4 bytes on 32-bit. The bottleneck in pointer chasing code is cache misses. In the limit where 100% of your code is chasing pointers, you'll incur twice as many cache misses on 64-bit as on 32-bit, hence the 2x slowdown.

For other types of programs, though, 64-bit can be faster than 32-bit, at least on x86/x64. x64 has twice as many general purpose registers as 32-bit x86, newer instructions like SSE/SSE2 are guaranteed to be available on x64 but not on 32-bit x86, and with more address space you can make different space-speed tradeoffs, such as storing instead of recomputing values or memory mapping large files.


Have you tried using Int64 instead of Int32 in your app? Have you tried changing out to an 8-bit character set? How do these things affect perf?

Do you run a regular hard drive or SSD?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜