Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use of C#? #1
Hi, thanks for the library, it's looking very useful - fills a big hole in concurrency abstractions in F# :)
Just looking for the first time over the code, why did you settle on using C# for the Core library? Is it really for performance or? I find C# a bit harder to read.
I'll need more time to read/play with this lib. Are there areas where you'd like contributions? Documentation comes to mind..
I initially wrote the synchronization protocols using tail recursive F#
Contributions, especially longer examples and documentation - perhaps in
On Fri, Feb 21, 2014 at 5:05 PM, Anton Tayanovskyy <firstname.lastname@example.org
I probably don't have the initial F# code anymore, but when I have the time I'll implement the Ch type with pure F# code. I have extensive experience doing low level direct hardware access programming and optimization at assembly language level on multiple processors (MC68k family (Atari ST & Amiga graphics demo programming), x86 family (e.g. PC graphics programming), SH-4 (low level optimizations on the Dreamcast platform)). I never looked at CIL code generated by F# or C# before starting to optimize the Hopac library stuff and I was quite surprised to see how complex the CIL code generated by the F# compiler for the synchronization loops was. I recall that F# was not only unable to optimize the loops to use gotos, but in the worst cases it generated code to allocate closures for the local functions used in the loops. I've since then spend quite some time looking at CIL code and there are many places where F# generates suboptimal code that, IMO, could be fixed easily by the compiler. I spend some time tweaking the code in F#, but then rewrote the stuff in C# and the performance difference was dramatic (literally a factor of 10 or more). A subset of C# maps rather directly to CIL and I spend some time learning to understand how it goes. Later I've tweaked the implementation by observing the code generated by the JIT (the current 64-bit JIT and RyuJit CTP2) with a debugger.
If/when you find time, it would be fantastic to pinpoint these issues. F# will optimize direct tailcalls from function F to itself into gotos, and other cases of tailcalls use the .tail instructions. So it would be really great to know which cases were not being represented in this way.
For IL codegen improvements it would also be great to have specific examples. So next time you're looking at IL, please do raise issues and we can work with the community to make fixes and incremental improvements.