
On 01 October 2004 08:45, Peter Simons wrote:
I am a happy user of hGetBufNonBlocking, but I have come to realize that mutable arrays are nicer to work with than pointers, so I have considered using hGetArray instead. I do, however, depend on the fact that the function returns as soon as it has read data -- even if less than requested --, like hGetBufNonBlocking does.
Is there currently a way to achieve this?
Not currently, but I could probably implement the equivalent (hGetArrayNonBlocking).
Am I right assuming that hGetBuf and hGetArray do not differ much performance-wise?
Hopefully not.
One of the reasons I am curious about using mutable arrays is because of Data.Array.Base.unsafeRead, which seems to be a *lot* faster than accessing the memory through a pointer. Is there anything comparable for pointer access?
I'm surprised if pointer access to memory is slower than unsafeRead. Could you post some code that we can peer at? Cheers, Simon

Simon Marlow writes:
Not currently, but I could probably implement the equivalent (hGetArrayNonBlocking).
If that were possible, I'd greatly appreciate it.
I'm surprised if pointer access to memory is slower than unsafeRead. Could you post some code that we can peer at?
Not right now, sorry. It's just a suspicion I have, but I haven't broken down the functions enough to be certain (or to post an isolated test case). But I will look at this further and let you know about it, once I have more "evidence". :-) Thanks for helping, Simon. Peter

On Fri, Oct 01, 2004 at 09:34:36PM +0100, Simon Marlow wrote:
Not currently, but I could probably implement the equivalent (hGetArrayNonBlocking).
It is perhaps not closely related, but could we also have Network.Socket recvFrom / sendTo working on raw buffers? I've attached a proposed implementation. It moves most of code to recvBufFrom and sendBufTo, and changes recvFrom / sendTo to use the *Buf* functions. It would be nice if these functions could be used to implement efficient recvFromArray / sendToArray (without copying), but I don't know if it's possible to get the pointer from MutableByteArray. Is there a danger that GC invalidates the pointer? Best regards, Tom -- .signature: Too many levels of symbolic links

On Sat, Oct 02, 2004 at 02:04:19PM +0200, Tomasz Zielonka wrote:
It is perhaps not closely related, but could we also have Network.Socket recvFrom / sendTo working on raw buffers?
I've attached a proposed implementation. It moves most of code to recvBufFrom and sendBufTo, and changes recvFrom / sendTo to use the *Buf* functions.
I reversed the order of ptr and nbytes parameters to recvFromBuf to match the order used by hGetBuf and hPutBuf. Best regards, Tom -- .signature: Too many levels of symbolic links

Simon Marlow writes:
I'm surprised if pointer access to memory is slower than unsafeRead.
You were right. Now that I have made some tests, the problem turned out to be elsewhere. Pointer access is not to blame. ;-) Peter
participants (3)
-
Peter Simons
-
Simon Marlow
-
Tomasz Zielonka