<HTML xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<HEAD><!-- Template generated by Exclaimer Template Editor on 05:38:36 Tuesday, 17 October 2017 -->
<STYLE type=text/css>P.6e29322b-2b13-4c3c-84b6-6ef47c6d8717 {
        MARGIN: 0cm 0cm 0pt
}
LI.6e29322b-2b13-4c3c-84b6-6ef47c6d8717 {
        MARGIN: 0cm 0cm 0pt
}
DIV.6e29322b-2b13-4c3c-84b6-6ef47c6d8717 {
        MARGIN: 0cm 0cm 0pt
}
TABLE.6e29322b-2b13-4c3c-84b6-6ef47c6d8717Table {
        MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
        page: Section1
}
</STYLE>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Generator" content="Microsoft Word 14 (filtered medium)" />
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</HEAD>

<BODY lang="EN-US" link="blue" vlink="purple">
<P>
<div class="WordSection1">
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Hi Lukas,<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Thank you very much for the quick and detailed reply. This explains it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Now I have a few further questions.<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">- It seems the reliable way to measure the amount of data in the message queue is setting message_queue_data process flag to off_heap beforehand (ideally at spawn time with
 spawn_opt), and retrieve the full message queue content with process_info(Pid,messages) – which must be fully scanned. Is there a better solution? (I originally aimed at refc binaries only because I just wanted a quick estimation, and in my case anything else
 was negligible.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">- May I suggest to improve the documentation of erlang:process_info(Pid, binary) by the below facts, also referring to message_queue_data process flag?<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">- Is it possible to implement a new process_info_item() of erlang:process_info/2 that gives information about binaries currently in the message queue but off-heap?<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">- The documentation suggests using off_heap message_queue_data “if the process potentially can get many messages”, but this is rather vague. Does this refer to processes
 expected to have many *<b>queued</b>* messages? I guess a process receiving but not queuing many messages performs better with on_heap (“Performance of the actual message passing is however generally better when not using flag off_heap.”).<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">   Andras<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style=font-size:10.0pt;font-family:"Tahoma","sans-serif">From:</span></b><span style=font-size:10.0pt;font-family:"Tahoma","sans-serif"> Lukas Larsson [mailto:lukas@erlang.org]
<br />
<b>Sent:</b> Tuesday, October 17, 2017 4:37 PM<br />
<b>To:</b> Bekes, Andras G (IST)<br />
<b>Cc:</b> erlang-questions@erlang.org<br />
<b>Subject:</b> Re: [erlang-questions] Where are the binaries in message queue but not part of process_info(Pid, binary) ?<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hello,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Oct 17, 2017 at 4:00 PM, Bekes, Andras G wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style=mso-margin-top-alt:auto;mso-margin-bottom-alt:auto>While investigating a system that transfers lots of refc binaries, I tried measuring the amount of data in the message queue of a process. I noticed that the binaries in the message
 queue are not always included in the result of process_info(Pid, binary).<o:p></o:p></p>
<p class="MsoNormal" style=mso-margin-top-alt:auto;mso-margin-bottom-alt:auto>In particular, when observing the binaries, I see time intervals when each of the new messages appear in the binary list, and time intervals when the binary list stays the same
 regardless of new messages in the queue.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">erlang:process_info(Pid, binary) returns the binaries that are currently on the heap of the process. Binaries in messages that have not yet been received may or may not be part of the heap depending on internal emulator optimizations.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The message_queue_data process flag explains this a little more and also gives a way to control it to some extent.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://erlang.org/doc/man/erlang.html#process_flag_message_queue_data">http://erlang.org/doc/man/erlang.html#process_flag_message_queue_data</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Lukas<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<BR /><BR />
<HR id=HR1 />
<P></P>
<P></P>
<P></P>
<P></P></P></BODY>
</HTML>