Selective receive optimization - same-function restriction still apply today?

There is this optimization regarding selective receives for simple request/response scenarios, going back to OTP R14something, which in a nutshell searches a message queue only from the point where a reference was created if all the clauses in a receive contain it (vs from the beginning).

Both a post on the old Mailing List as well as the respective chapter in LYSE (the box at the very end of the chapter) mention that the creation of the reference and the receive have to happen in the same function (which is probably incorrect even, I assume that it has to be within the same run of a function).

However, the relevant OTP docs does not contain this passage. So I wonder, does this same-function restriction still apply as of today (OTP 27 at the time of this writing)? If so, shouldn’t it be added to the documentation, if only for completeness’ sake? If not, when was it lifted?

2 Likes

It does not apply anymore. We did a lot of work in Erlang/OTP 24 to improve the situation and have done more after that.

5 Likes

Thanks :smiley: But wow, this completely went by me :dizzy_face:

2 Likes