You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ch...@apache.org on 2014/04/29 21:00:10 UTC
svn commit: r1591056 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm:
JobManagerConverter.java scheduler/RmJob.java scheduler/Share.java
Author: challngr
Date: Tue Apr 29 19:00:09 2014
New Revision: 1591056
URL: http://svn.apache.org/r1591056
Log:
UIMA-3360 Use 'investment' values from OR to make better choices for share eviction.
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java
uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java
uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java?rev=1591056&r1=1591055&r2=1591056&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java Tue Apr 29 19:00:09 2014
@@ -238,10 +238,10 @@ public class JobManagerConverter
DuccId id = proc.getDuccId();
Share s = new Share(id, m, j, m.getShareOrder()); // guess share order; scheduler will reset when it recovers job
long mem = proc.getResidentMemory();
-
+ long investment = proc.getWiMillisInvestment();
logger.info(methodName, j.getId(), "Assigning share in state", state, "pid", pid, "for recovery", s.toString());
j.recoverShare(s);
- s.update(j.getId(), mem, state, proc.getTimeWindowInit(), proc.getTimeWindowRun(), pid);
+ s.update(j.getId(), mem, investment, state, proc.getTimeWindowInit(), proc.getTimeWindowRun(), pid);
}
}
logger.info(methodName, j.getId(), "Scheduling for recovery.");
@@ -512,11 +512,12 @@ public class JobManagerConverter
Share s = scheduler.getShare(p.getDuccId());
long mem = p.getResidentMemory();
+ long investment = p.getWiMillisInvestment();
ProcessState state = p.getProcessState();
String pid = p.getPID();
logger.info(methodName, jobid, "New process ", s.toString(), mem, state, pid);
- if ( ! s.update(jobid, mem, state, p.getTimeWindowInit(), p.getTimeWindowRun(), pid) ) {
+ if ( ! s.update(jobid, mem, investment, state, p.getTimeWindowInit(), p.getTimeWindowRun(), pid) ) {
// TODO: probably change to just a warning and cancel the job - for now I want an attention-getter
throw new SchedulingException(jobid, "Process assignemnt arrives for share " + s.toString() +
" but jobid " + jobid + " does not match share " + s.getJob().getId());
@@ -561,18 +562,22 @@ public class JobManagerConverter
/** extreme debugging only*/
if ( logger.isTrace() ) {
logger.trace(methodName, jobid,
- "\n\tReconciling. incoming.(pid, mem, state, share, initTime)",
+ "\n\tReconciling. incoming.(did, pid, mem, state, share, initTime, investment)",
+ pl.getDuccId(),
pl.getPID(),
pl.getResidentMemory(),
pl.getProcessState(),
shareL,
init_timeL,
- "\n\tReconciling. existing.(pid, mem, state, share, initTime)",
+ pl.getWiMillisInvestment(),
+ "\n\tReconciling. existing.(did, pid, mem, state, share, initTime, investment)",
+ pr.getDuccId(),
pr.getPID(),
pr.getResidentMemory(),
pr.getProcessState(),
shareR,
- init_timeR
+ init_timeR,
+ pr.getWiMillisInvestment()
);
} else {
if ( (pr.getPID() == null) && (pl.getPID() != null) ) {
@@ -589,6 +594,7 @@ public class JobManagerConverter
}
long mem = pl.getResidentMemory();
+ long investment = pl.getWiMillisInvestment();
ProcessState state = pl.getProcessState();
String pid = pl.getPID();
Share s = scheduler.getShare(pl.getDuccId());
@@ -606,7 +612,7 @@ public class JobManagerConverter
logger.info(methodName, jobid, "Process", pl.getPID(), "marked complete because it is purged. State:", state);
}
- if ( ! s.update(jobid, mem, state, pl.getTimeWindowInit(), pl.getTimeWindowRun(), pid) ) {
+ if ( ! s.update(jobid, mem, investment, state, pl.getTimeWindowInit(), pl.getTimeWindowRun(), pid) ) {
// TODO: probably change to just a warning and cancel the job - for now I want an attention-getter
throw new SchedulingException(jobid, "Process update arrives for share " + s.toString() +
" but jobid " + jobid + " does not match job in share " + s.getJob().getId());
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java?rev=1591056&r1=1591055&r2=1591056&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java Tue Apr 29 19:00:09 2014
@@ -1330,18 +1330,32 @@ public class RmJob
public int compare(Share s1, Share s2)
{
if ( s1.equals(s2) ) return 0;
- // First divide them into two pools:
- // not-initialized shares always sort LESS than initialized shares
- if ( ! s1.isInitialized() ) {
- if ( s2.isInitialized() ) return -1;
- // both not initialized. sort on less time spent initializing so far (fall through)
- } else {
- if ( ! s2.isInitialized() ) return 1;
- // bot initialized. Again sort on less time spent ever in init. (fall through)
+
+ int mask = 0;
+ if ( s1.isInitialized() ) mask |= 0x02;
+ if ( s2.isInitialized() ) mask |= 0x01;
+
+ switch ( mask ) {
+ case 0: // neither is initialized
+ return ( (int) (s1.getInitializationTime() - s2.getInitializationTime()) );
+ case 1: // s1 not initialized, s2 is
+ return -1;
+ case 2: // s2 initialized, s1 not
+ return 1;
+ default: // both initialized, compare investments
}
- return ( (int) (s1.getInvestment() - s2.getInvestment()) );
- }
+ long i1 = s1.getInvestment();
+ long i2 = s2.getInvestment();
+ if (i1 == i2 ) {
+ // Maybe splitting hairs. Neither share has investment but both are initialized. Apparently
+ // we're waiting for the data to arrive. Choose the most recently assigned as it probably has the least
+ // actual progress.
+ return (int) (s2.getId().getFriendly() - s1.getId().getFriendly());
+ } else {
+ return (int) (i1 - i2);
+ }
+ }
}
@Override
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java?rev=1591056&r1=1591055&r2=1591056&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java Tue Apr 29 19:00:09 2014
@@ -53,6 +53,8 @@ public class Share
private boolean purged = false; // share is forcibly removed because it's machine died
private boolean fixed = false; // if true, can't be preempted
+ private long investment = 0; // Current time for all ACTIVE work items in the process
+
@SuppressWarnings("unused")
private long resident_memory = 0;
@SuppressWarnings("unused")
@@ -211,11 +213,12 @@ public class Share
// so we don't end up counting this job more than it deserves.
}
- public boolean update(DuccId jobid, long mem, ProcessState state, ITimeWindow init_time, ITimeWindow run_time, String pid)
+ public boolean update(DuccId jobid, long mem, long investment, ProcessState state, ITimeWindow init_time, ITimeWindow run_time, String pid)
{
if ( ! jobid.equals(job.getId()) ) return false; // something has gone horribly wrong
this.resident_memory = mem;
+ this.investment = investment;
this.state = state;
this.pid = pid;
this.init_time = init_time;
@@ -254,8 +257,7 @@ public class Share
*/
long getInvestment()
{
- if ( init_time == null ) return 0;
- return init_time.getElapsedMillis();
+ return investment;
}
/**