Re: Getting number of messages in MessageBox

2013-08-06 Thread Marek Janukowicz
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


Re: Getting number of messages in MessageBox

2013-08-06 Thread Gabi

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?


Re: Getting number of messages in MessageBox

2013-08-06 Thread 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?

-- 
Marek Janukowicz


Re: Getting number of messages in MessageBox

2013-08-06 Thread dennis luehring

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?




Re: Getting number of messages in MessageBox

2013-08-06 Thread Marek Janukowicz
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


Re: Getting number of messages in MessageBox

2013-08-06 Thread Gabi

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.


Re: Getting number of messages in MessageBox

2013-08-06 Thread Sean Kelly
On Aug 5, 2013, at 4:18 PM, Marek Janukowicz ma...@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...

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.

Re: Getting number of messages in MessageBox

2013-08-06 Thread Dmitry Olshansky

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


Re: Getting number of messages in MessageBox

2013-08-06 Thread Sean Kelly
On Aug 6, 2013, at 1:27 PM, Dmitry Olshansky dmitry.o...@gmail.com wrote:

 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 ...

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.

Getting number of messages in MessageBox

2013-08-05 Thread 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...

-- 
Marek Janukowicz


Re: Getting number of messages in MessageBox

2013-08-05 Thread Andrej Mitrovic
On 8/6/13, Marek Janukowicz ma...@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.


Re: Getting number of messages in MessageBox

2013-08-05 Thread Ali Çehreli

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