BTW, how much memory does this machine have? Is it 32g or 16g?
It's 36Gb.
% expr `sysctl -n hw.memsize` / 1024 / 1024 / 1024
36
The bottom line here is that you ultimately need to constrain how quickly you complete write calls to be roughly in line with your underlying ability to transfer data.
My attempt at this was through modifying the socket polling algorithm.
The decision on whether it's a read or a write event that's occurred is taken in the sock_upcall callback.
The socket's receive buffer is queried about whether there's any data available via a call to sock_getsockopt(SO_NREAD). If there is, a thread waiting to read data is sent a read event wakeup() call. Otherwise, the algorithm considers this to be a write event and a thread waiting to write data is sent a wakeup() call. This doesn't take into account whether or not there's room in the send buffer.
It's a 'poor' man's socket polling algo, due to functions like sock_setupcalls(), soreadable(), and sowriteable() being a part of the private API.
To try and bring the rate the data is being written in line with the rate it's being transferred, I tried modifying the write part of the algorithm by considering it a write event only if there's no more data left in the socket's send buffer via a call to sock_getsockopt(SO_NWRITE).
That didn't help remedy the problem.
I can't think of other ways of achieving this at the moment.
Topic:
App & System Services
SubTopic:
Core OS
Tags: