Discussion:
[erlang-patches] Optimise io requests for long message queues
unknown
2014-06-27 17:07:03 UTC
Permalink
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
unknown
2014-09-17 10:30:49 UTC
Permalink
Post by unknown
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.
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
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
unknown
2014-09-19 18:11:58 UTC
Permalink
Post by unknown
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
"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?
I added a test, and updated the documentation. The pull request can be
found here:

https://github.com/erlang/otp/pull/478

Regards,
Magnus
unknown
2014-09-22 05:57:49 UTC
Permalink
Thank you!
Post by unknown
Post by unknown
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
"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?
I added a test, and updated the documentation. The pull request can be
https://github.com/erlang/otp/pull/478
Regards,
Magnus
--
/Henrik Nord Erlang/OTP
Loading...