You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@reef.apache.org by Jason Jeong <cu...@gmail.com> on 2016/07/25 23:53:19 UTC

.NET Driver-side threads

Hi,

While experimenting with the .NET Driver, I noticed an interesting fact:
If an OnNext(IDriverStarted driverStarted) thread blocks (e.g. Thread.Sleep(),
Monitor.Wait()) after submitting an evaluator request via
IEvaluatorRequestor, then evaluators fail to spawn until the thread is
unblocked.
I'm pretty sure this is not the case for the Java-side;
EventHandler<AllocatedEvaluator>s will fire regardless of whether
EventHandler<StartTime>s have finished or not.

Does the transition between .NET and Java via JNI have something do with
this?
Just to provide some context, I'm trying to make the OnNext(IDriverStarted
driverStarted) thread wait until a certain amount of evaluators have
spawned and have passed through OnNext(IAllocatedEvaluator
allocatedEvaluator).

Thanks,
Jason

Re: .NET Driver-side threads

Posted by Jason Jeong <cu...@gmail.com>.
Hi all,

I found the cause; the answer's in
org.apache.reef.javabridge.generic.JobDriver.
The handlers for the job start event and evaluator allocated event both try
to take locks on the JobDriver instance (synchronized (JobDriver.this)),
meaning that blocking the driver thread without letting go of the lock will
also block threads for the evaluator allocated event too.
There is no such default synchronization for Java REEF applications, so
that's why this problem wasn't seen on the Java side.

It seems that the JobDriver class is using some thread-unsafe data
structures, hence the synchronization.
I'm not sure if simply converting them to thread-safe counterparts can
allow us to remove synchronization.

Thanks,
Jason

On Tue, Jul 26, 2016 at 12:24 PM, Dudoladov, Sergey <
sergey.dudoladov@tu-berlin.de> wrote:

> Hi,
>
> I've found ThreadPoolStage.cs in Org.Apache.REEF.Wake.Impl on the .NET
> side.
> Not sure if REEF actually uses it, though.
>
> Best,
> Sergey.

Re: .NET Driver-side threads

Posted by "Dudoladov, Sergey" <se...@tu-berlin.de>.
Hi, 

I've found ThreadPoolStage.cs in Org.Apache.REEF.Wake.Impl on the .NET side.
Not sure if REEF actually uses it, though.

Best,
Sergey.

Re: .NET Driver-side threads

Posted by Markus Weimer <ma...@weimo.de>.
On 2016-07-26 09:41, Andrew Chung wrote:
> IIRC REEF.NET doesn't have the equivalent of ThreadPoolStage yet.
> Implementing it will definitely be an improvement!

Before we run off and do that, we should research what is already there 
in Rx. In many ways, the local scheduling in Wake/Java was inspired by 
Rx, and it would not surprise me if there was an equivalent to 
`ThreadPoolStage` in Rx.

Markus

Re: .NET Driver-side threads

Posted by Andrew Chung <af...@gmail.com>.
Hi Jason,

Yes, I believe so, as .NET Driver handler threads are not dispatched
with a ThreadPoolStage. IIRC REEF.NET doesn't have the equivalent of
ThreadPoolStage yet. Implementing it will definitely be an
improvement!

Thanks,
Andrew

On Mon, Jul 25, 2016 at 4:53 PM, Jason Jeong <cu...@gmail.com> wrote:
> Hi,
>
> While experimenting with the .NET Driver, I noticed an interesting fact:
> If an OnNext(IDriverStarted driverStarted) thread blocks (e.g. Thread.Sleep(),
> Monitor.Wait()) after submitting an evaluator request via
> IEvaluatorRequestor, then evaluators fail to spawn until the thread is
> unblocked.
> I'm pretty sure this is not the case for the Java-side;
> EventHandler<AllocatedEvaluator>s will fire regardless of whether
> EventHandler<StartTime>s have finished or not.
>
> Does the transition between .NET and Java via JNI have something do with
> this?
> Just to provide some context, I'm trying to make the OnNext(IDriverStarted
> driverStarted) thread wait until a certain amount of evaluators have
> spawned and have passed through OnNext(IAllocatedEvaluator
> allocatedEvaluator).
>
> Thanks,
> Jason