Feature Req: Low Load Advice

Jun 30, 2008 at 9:18 PM
Hello, first of all thanks for your work.

I'm working in a project that uses a producer - consumer strategy  for loading data into a system.
In this project i need to produce data continuously, so i can't wait for idle events because
this could lead to lower than expected workloads.

If you have any suggestions or you know  there is another way already implemented please advise me. 

If there isn't any workaround or direct implementation, i'd like to propose a solution based on
a "LowLoadThreashold" that warns when the processing queue is becoming empty.

This could be implemented as:

1) Change IWorkItemsGroup interface adding //(Same as onIdle plus LowLoadThreashold)
     * int LowLoadThreashold{ get; set; }
     * void WaitLowLoad();
     * void WaitLowLoadTimeSpan timeout);
     * bool IsLowLoad { get; }
     *event WorkItemsGroupLowLoadHandler OnLowLoad;
     *void ResetLowLevel() -> set the event to the correct calue and raise if appropiate

2) Implementing it in the WorkItemsGroup class. SmartThreadPool implementation returns NotImplementedException.


The implementation should check in WorkItemsGroup.EnqueueToSTPNextWorkItem whether the current workload goes below the threshold
and if so,  set and raise the events.

Thanks in advance.





Coordinator
Jul 1, 2008 at 7:24 AM
Hi,

Thank you for your suggestion, I am always glad when people are looking at the code.

A solution I can think of is using the PostExecuteWorkItemCallback in a WorkItemsGroup.
You can attach a PostExecuteWorkItemCallback to every work item in a WorkItemsGroup.
It should check if the WorkItemsGroup.WaitingCallbacks < LowLoadThreashold and then initiate your action.
The action should occur immediately, either by calling a method directly or queuing a work item with high priority
or else by the time the action will execute it won't be relevant.

Is this solution answers your needs?

Ami

juanpascual wrote:
Hello, first of all thanks for your work.

I'm working in a project that uses a producer - consumer strategy  for loading data into a system.
In this project i need to produce data continuously, so i can't wait for idle events because
this could lead to lower than expected workloads.

If you have any suggestions or you know  there is another way already implemented please advise me. 

If there isn't any workaround or direct implementation, i'd like to propose a solution based on
a "LowLoadThreashold" that warns when the processing queue is becoming empty.

This could be implemented as:

1) Change IWorkItemsGroup interface adding //(Same as onIdle plus LowLoadThreashold)
     * int LowLoadThreashold{ get; set; }
     * void WaitLowLoad();
     * void WaitLowLoadTimeSpan timeout);
     * bool IsLowLoad { get; }
     *event WorkItemsGroupLowLoadHandler OnLowLoad;
     *void ResetLowLevel() -> set the event to the correct calue and raise if appropiate

2) Implementing it in the WorkItemsGroup class. SmartThreadPool implementation returns NotImplementedException.


The implementation should check in WorkItemsGroup.EnqueueToSTPNextWorkItem whether the current workload goes below the threshold
and if so,  set and raise the events.

Thanks in advance.








Jul 1, 2008 at 1:55 PM
Ami, thanks for your response.
I think your suggestion solves the problem so i will try this way.
Anyway, i think it would be useful to have some kind of loading control
built into the STP api, it could be performance counters threshold advisers for example,
that allows better and easier control from outside the pool.

Thanks again.