[Haskell-cafe] Marshalling
Hello I'm wondering if anyone ever benchmarked marshalling in Haskell/GHC. No matter how much I optimize my Haskell code my program still seems to run slow, which leads me to beleive that Marshalling is painfully slow. Does anyone know a way I can test this and fix it? Regards, Phyx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Marshalling
On Tue, Jul 13, 2010 at 13:29, Phyx loneti...@gmail.com wrote: Hello I'm wondering if anyone ever benchmarked marshalling in Haskell/GHC. No matter how much I optimize my Haskell code my program still seems to run slow, which leads me to beleive that Marshalling is painfully slow. Does anyone know a way I can test this and fix it? What kind of marshalling are you referring to? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Marshalling
Marshalling large amount of data from and to C http://phyx.pastebin.com/WXGBr1bX shows the code I use to do this (it's autogenerated, so just looking at 1 block should be enough) The tool is mine, so i can change the code it generates, but i would need to know how to do it better first. On Tue, Jul 13, 2010 at 3:30 PM, Magnus Therning mag...@therning.orgwrote: On Tue, Jul 13, 2010 at 13:29, Phyx loneti...@gmail.com wrote: Hello I'm wondering if anyone ever benchmarked marshalling in Haskell/GHC. No matter how much I optimize my Haskell code my program still seems to run slow, which leads me to beleive that Marshalling is painfully slow. Does anyone know a way I can test this and fix it? What kind of marshalling are you referring to? /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Marshalling
That code is effectively copying the data (thats what those peeks / pokes do), so it stands to reason it would be slow by most performance standards. The reason ByteStrings are fast when used both by C and Haskell is there is a zero-copy `useAsCString`. Cheers, Thomas On Tue, Jul 13, 2010 at 7:49 AM, Phyx loneti...@gmail.com wrote: Marshalling large amount of data from and to C http://phyx.pastebin.com/WXGBr1bX shows the code I use to do this (it's autogenerated, so just looking at 1 block should be enough) The tool is mine, so i can change the code it generates, but i would need to know how to do it better first. On Tue, Jul 13, 2010 at 3:30 PM, Magnus Therning mag...@therning.org wrote: On Tue, Jul 13, 2010 at 13:29, Phyx loneti...@gmail.com wrote: Hello I'm wondering if anyone ever benchmarked marshalling in Haskell/GHC. No matter how much I optimize my Haskell code my program still seems to run slow, which leads me to beleive that Marshalling is painfully slow. Does anyone know a way I can test this and fix it? What kind of marshalling are you referring to? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Marshalling
I understand that part, but the strings are generated from SDocs, and So unless internally SDoc doesn't use String then I'm afraid there's nothing I can do about that :/ Or rather, Is there a way to efficiently make CWStrings from SDocs? Regards, Phyx On Tue, Jul 13, 2010 at 6:56 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: That code is effectively copying the data (thats what those peeks / pokes do), so it stands to reason it would be slow by most performance standards. The reason ByteStrings are fast when used both by C and Haskell is there is a zero-copy `useAsCString`. Cheers, Thomas On Tue, Jul 13, 2010 at 7:49 AM, Phyx loneti...@gmail.com wrote: Marshalling large amount of data from and to C http://phyx.pastebin.com/WXGBr1bX shows the code I use to do this (it's autogenerated, so just looking at 1 block should be enough) The tool is mine, so i can change the code it generates, but i would need to know how to do it better first. On Tue, Jul 13, 2010 at 3:30 PM, Magnus Therning mag...@therning.org wrote: On Tue, Jul 13, 2010 at 13:29, Phyx loneti...@gmail.com wrote: Hello I'm wondering if anyone ever benchmarked marshalling in Haskell/GHC. No matter how much I optimize my Haskell code my program still seems to run slow, which leads me to beleive that Marshalling is painfully slow. Does anyone know a way I can test this and fix it? What kind of marshalling are you referring to? /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Marshalling arrays without flakiness?
Hi, I would like to know whether there is a good way to marshal the following structure to C without using pointer arithmetic done by a programmer (as opposed to a tool). typedef struct{ double a[10]; double b[10]; double b[10]; } foo; I don't need this functionality, but it would make Haskell - C interfaces less flaky. Basically, writing Haskell - C interfaces seem to be a very unpopular thing to do (as opposed to C - Haskell interfaces). For example, on Hackage (actually a checkout of a few months ago) there is only one package using pokeArray and it is not pretty; it uses pointer arithmetic and all other kinds of hard-coded addresses. If I change the order of the C fields it will break, if I change the length of the buffer they use, it breaks. Just look at it, and it will break ;) If you are a bit creative, it is possible to make it work already, by using the best features of both hsc2hs and c2hs, but it is hardly elegant. I suppose the real solution would be to extend c2hs with an offsetof function (for which patches already exist, btw), but it might be that I have missed some other solution. -- Best Regards, Ron de Bruijn, Developer, Gamr7 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Marshalling recursive data structures with the FFI
Hi, A few days ago we published an article (http://gamr7.com/blog/?p=66) on using the FFI to marshal recursive data structures between Haskell and C (or Python if you use ctypes). Best regards, Ron de Bruijn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe