[erlang-patches] Optimise io requests for long message queues

Henrik Nord henrik@REDACTED
Wed Sep 17 12:30:49 CEST 2014


On 2014-06-27 19:07, Magnus Henoch wrote:
> This patch reduces the run time of non-raw I/O when the calling process
> has a long message queue, by using the monitor reference to trigger the
> selective receive optimisation.
>
> Here is a little test program:
> https://gist.github.com/legoscia/e0ac1bd1f640c9489609
>
> Without my change, the run time of the call to file:write/2 increases as
> the message queue length increases, while with my patch, the run time
> stays constant.
>
> I was a bit unsure about removing the 'EXIT' clause from the receive,
> but I've mostly convinced myself that this case should be fully handled
> by the 'DOWN' clause, as the process in question is being monitored.
>
> git fetch git://github.com/legoscia/otp.git io-message-queue-optimisation
>
> https://github.com/legoscia/otp/compare/legoscia:io-message-queue-optimisation
> https://github.com/legoscia/otp/compare/legoscia:io-message-queue-optimisation.patch
>
> Regards,
> Magnus
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches
Hi!


we would like a test case which ensures that the optimization is not 
broken: An example of such test can be found in 
gen_server_SUITE:call_with_huge_message_queue

The documentation needs a minor fix in the part that talks about "a more 
complicated client" - maybe something similar to this:

"The io module monitors the I/O server, and uses the monitor reference 
as the ReplyAs datum. A more complicated client could have several 
outstanding I/O requests to the same I/O server and would then use 
different references (or something else) to differentiate among the 
incoming IO replies."

When you have addressed the issues above could you also create a 
pull-request for this?

-- 
/Henrik Nord Erlang/OTP




More information about the erlang-patches mailing list