www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Getting number of messages in MessageBox

reply Marek Janukowicz <marek janukowicz.net> writes:
I'm using std.concurrency message passing and I'd like to check which thread 
might be a bottleneck. The easiest would be check number of messages piled 
up for each of them, but I could not find a way to do that. Is it possible? 
Every detail about MessageBox seems to be hidden...

-- 
Marek Janukowicz
Aug 05 2013
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/05/2013 04:18 PM, Marek Janukowicz wrote:
 I'm using std.concurrency message passing and I'd like to check which thread
 might be a bottleneck. The easiest would be check number of messages piled
 up for each of them, but I could not find a way to do that. Is it possible?
 Every detail about MessageBox seems to be hidden...
Would setMaxMailboxSize() be helpful? void setMaxMailboxSize(Tid tid, size_t messages, bool function(Tid) onCrowdingDoThis); You can set a limit (perhaps that is lower than normal operation) and report whenever a particular Tid's MessageBox gets full. Ali
Aug 05 2013
parent reply Marek Janukowicz <marek janukowicz.net> writes:
Ali Çehreli wrote:

 On 08/05/2013 04:18 PM, Marek Janukowicz wrote:
 I'm using std.concurrency message passing and I'd like to check which
 thread might be a bottleneck. The easiest would be check number of
 messages piled up for each of them, but I could not find a way to do
 that. Is it possible? Every detail about MessageBox seems to be hidden...
Would setMaxMailboxSize() be helpful? void setMaxMailboxSize(Tid tid, size_t messages, bool function(Tid) onCrowdingDoThis); You can set a limit (perhaps that is lower than normal operation) and report whenever a particular Tid's MessageBox gets full.
Well, while this could help a little, it's not really what I'm looking for. I'd like to dump message counts for various threads periodically and see how it fluctuates over time. With the solution you propose I could only check how often a certain limit is hit. -- Marek Janukowicz
Aug 05 2013
parent reply "Gabi" <galim120 bezeqint.net> writes:
On Tuesday, 6 August 2013 at 06:15:20 UTC, Marek Janukowicz wrote:
 Ali Çehreli wrote:

 On 08/05/2013 04:18 PM, Marek Janukowicz wrote:
 I'm using std.concurrency message passing and I'd like to 
 check which
 thread might be a bottleneck. The easiest would be check 
 number of
 messages piled up for each of them, but I could not find a 
 way to do
 that. Is it possible? Every detail about MessageBox seems to 
 be hidden...
Would setMaxMailboxSize() be helpful? void setMaxMailboxSize(Tid tid, size_t messages, bool function(Tid) onCrowdingDoThis); You can set a limit (perhaps that is lower than normal operation) and report whenever a particular Tid's MessageBox gets full.
Well, while this could help a little, it's not really what I'm looking for. I'd like to dump message counts for various threads periodically and see how it fluctuates over time. With the solution you propose I could only check how often a certain limit is hit.
Why not go for the trivial solution - just increase/decrease a counter for each push/pop message?
Aug 06 2013
parent reply Marek Janukowicz <marek janukowicz.net> writes:
Gabi wrote:

 Why not go for the trivial solution - just increase/decrease a
 counter for each push/pop message?
Yeah, that's most likely what I'll end up with, but it's a pity such information exists and I only can't access it because someone decided to make it private... or should I file a bug (or rather feature request) about it? -- Marek Janukowicz
Aug 06 2013
parent reply dennis luehring <dl.soluz gmx.net> writes:
Am 06.08.2013 09:30, schrieb Marek Janukowicz:
 Gabi wrote:

 Why not go for the trivial solution - just increase/decrease a
 counter for each push/pop message?
Yeah, that's most likely what I'll end up with, but it's a pity such information exists and I only can't access it because someone decided to make it private... or should I file a bug (or rather feature request) about it?
the question is do the published counter then needs locking - and make it slow for all - just for beeing getable?
Aug 06 2013
parent reply Marek Janukowicz <marek janukowicz.net> writes:
dennis luehring wrote:
 the question is do the published counter then needs locking - and make
 it slow for all - just for beeing getable?
Good point - but I believe the code operating on the counter is synchronized already, so synchronized getter would not really slow things down. -- Marek Janukowicz
Aug 06 2013
parent "Gabi" <galim120 bezeqint.net> writes:
On Tuesday, 6 August 2013 at 07:47:10 UTC, Marek Janukowicz wrote:
 dennis luehring wrote:
 the question is do the published counter then needs locking - 
 and make
 it slow for all - just for beeing getable?
Good point - but I believe the code operating on the counter is synchronized already, so synchronized getter would not really slow things down.
I agree that this is much needed feature. In python for example, the threaded Queue class has qsize() method that returns the APPROX size of the queue. Without it my life would be much harder-I use it frequently.
Aug 06 2013
prev sibling next sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
06-Aug-2013 03:18, Marek Janukowicz пишет:
 I'm using std.concurrency message passing and I'd like to check which thread
 might be a bottleneck. The easiest would be check number of messages piled
 up for each of them, but I could not find a way to do that. Is it possible?
 Every detail about MessageBox seems to be hidden...
This is sadly intentional. The reasons must be due to some efficient concurrent queues not being able to produce reliable item count if at all. However this seems at odds with setMaxMailboxSize ... -- Dmitry Olshansky
Aug 06 2013
parent Sean Kelly <sean invisibleduck.org> writes:
On Aug 6, 2013, at 1:27 PM, Dmitry Olshansky <dmitry.olsh gmail.com> =
wrote:

 06-Aug-2013 03:18, Marek Janukowicz =D0=BF=D0=B8=D1=88=D0=B5=D1=82:
 I'm using std.concurrency message passing and I'd like to check which =
thread
 might be a bottleneck. The easiest would be check number of messages =
piled
 up for each of them, but I could not find a way to do that. Is it =
possible?
 Every detail about MessageBox seems to be hidden...
=20
=20 This is sadly intentional. The reasons must be due to some efficient =
concurrent queues not being able to produce reliable item count if at = all.
=20
 However this seems at odds with setMaxMailboxSize ...
The lack of a function to get the current mailbox size is mostly an = oversight. It would be easy to return the same message count used by = setMaxMailboxSize. This isn't an exact count, since that would be = inefficient as you say, but it's a reasonable approximation. So I = wouldn't use the returned message count as a pivotal part of a protocol = design, for example, but it would be fine for determining whether a = consumer is being overwhelmed by requests. That said, with the possible exception of setMaxMailboxSize allowing one = thread to affect the behavior of another thread's mailbox, I think the = current functionality should all extend to interprocess messaging = without alteration. I'm not sure that this could be done for a = getMailboxSize call. Certainly not with any semblance of efficiency = anyway. But perhaps it's reasonable to have some subset of = functionality that only works on local threads so long as the core = messaging API doesn't have such limitations.=
Aug 06 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 8/6/13, Marek Janukowicz <marek janukowicz.net> wrote:
 I'm using std.concurrency message passing and I'd like to check which thread
 might be a bottleneck. The easiest would be check number of messages piled
 up for each of them, but I could not find a way to do that. Is it possible?

 Every detail about MessageBox seems to be hidden...
I wanted this too, and filed Issue 5806 many months ago: http://d.puremagic.com/issues/show_bug.cgi?id=5806 Hopefully someone steps up and implements the feature.
Aug 05 2013
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
On Aug 5, 2013, at 4:18 PM, Marek Janukowicz <marek janukowicz.net> =
wrote:

 I'm using std.concurrency message passing and I'd like to check which =
thread=20
 might be a bottleneck. The easiest would be check number of messages =
piled=20
 up for each of them, but I could not find a way to do that. Is it =
possible?=20
 Every detail about MessageBox seems to be hidden...
Not currently. It wouldn't be hard to add a function to get the count = used by setMaxMailboxSize though. I'll make a note to add it.=
Aug 05 2013