Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cuebot/src/main/java/com/imageworks/spcue/LayerDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class LayerDetail extends LayerEntity implements LayerInterface {
public int timeout_llu;
public int dispatchOrder;
public int totalFrameCount;
// Concurrency slots each frame requires (slot-based scheduling). 0 = not slot-based.
public int slotsRequired;

public Set<String> tags = new LinkedHashSet<String>();
public Set<String> services = new LinkedHashSet<String>();
Expand Down
3 changes: 3 additions & 0 deletions cuebot/src/main/java/com/imageworks/spcue/VirtualProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class VirtualProc extends FrameEntity implements ProcInterface {
public int gpusReserved;
public long gpuMemoryReserved;
public long gpuMemoryUsed;

// Concurrency slots reserved by this proc (slot-based scheduling). 0 for regular procs.
public int slotsReserved;
public long gpuMemoryMax;

public boolean unbooked;
Expand Down
9 changes: 9 additions & 0 deletions cuebot/src/main/java/com/imageworks/spcue/dao/GroupDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ public interface GroupDao {
*/
public void updateMaxCores(GroupInterface group, int value);

/**
* Sets the max concurrent slots for slot-based layers in the group's folder. -1 unlimited, 0
* reject-all, N caps at N.
*
* @param group
* @param value
*/
public void updateMaxSlots(GroupInterface group, int value);

/**
* Set the minimum number of cores for this group
*
Expand Down
9 changes: 9 additions & 0 deletions cuebot/src/main/java/com/imageworks/spcue/dao/HostDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ public interface HostDao {
*/
void updateThreadMode(HostInterface host, ThreadMode mode);

/**
* Sets the host's concurrent slots limit. -1 disables slot mode (regular host); >= 0 makes the
* host slot-based, running only slot layers up to this many concurrent slots.
*
* @param host HostInterface
* @param limit int
*/
void updateConcurrentSlotsLimit(HostInterface host, int limit);

/**
* Update the specified host's hardware information.
*
Expand Down
16 changes: 16 additions & 0 deletions cuebot/src/main/java/com/imageworks/spcue/dao/JobDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public interface JobDao {
*/
public void updateMaxCores(GroupInterface g, int cores);

/**
* Updates all jobs in the specified group to the max slots value.
*
* @param g
* @param slots
*/
public void updateMaxSlots(GroupInterface g, int slots);

/**
* Updates all jobs in the specifid group to the min cores value.
*
Expand Down Expand Up @@ -306,6 +314,14 @@ public interface JobDao {
*/
void updateMaxCores(JobInterface j, int v);

/**
* Sets the job's max concurrent slots for slot-based layers. -1 unlimited, 0 reject-all.
*
* @param j
* @param v
*/
void updateMaxSlots(JobInterface j, int v);

/**
* sets the jobs new min gpu value
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,13 @@ public interface SubscriptionDao {
* @param size int
*/
void updateSubscriptionBurst(SubscriptionInterface sub, int size);

/**
* update the subscription max concurrent slots for slot-based layers (-1 unlimited, 0
* reject-all, N cap)
*
* @param sub SubscriptionInterface
* @param maxSlots int
*/
void updateSubscriptionMaxSlots(SubscriptionInterface sub, int maxSlots);
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ public void updateMaxCores(GroupInterface group, int value) {
}
}

@Override
public void updateMaxSlots(GroupInterface group, int value) {
// Slots are whole counts: -1 = unlimited, 0 = reject-all, N = cap. Normalize any
// negative to the -1 sentinel.
if (value < 0) {
value = CueUtil.FEATURE_DISABLED;
}

getJdbcTemplate().update("UPDATE folder_resource SET int_max_slots=? WHERE pk_folder=?",
value, group.getId());

if (accountingNotifier.isEnabled() && showDao.isSchedulerManaged(group.getShowId())) {
accountingNotifier.notifyFolderMaxSlots(group.getId(), value);
}
}

@Override
public void updateMinCores(GroupInterface group, int value) {
if (value < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,17 @@ public void updateThreadMode(HostInterface host, ThreadMode mode) {
mode.getNumber(), host.getHostId());
}

@Override
public void updateConcurrentSlotsLimit(HostInterface host, int limit) {
// -1 disables slot mode; >= 0 caps concurrent slots. The per-host slot cap is enforced
// in the scheduler's host cache (not the accounting store), so no NOTIFY is emitted.
if (limit < 0) {
limit = -1;
}
getJdbcTemplate().update("UPDATE host SET int_concurrent_slots_limit=? WHERE pk_host=?",
limit, host.getHostId());
}

@Override
public void updateHostOs(HostInterface host, String os) {
getJdbcTemplate().update("UPDATE host_stat SET str_os=? WHERE pk_host=?", os,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,32 @@ public void updateMaxCores(JobInterface j, int v) {
}
}

@Override
public void updateMaxSlots(GroupInterface g, int v) {
// Slots are whole counts: -1 unlimited, 0 reject-all, N cap.
if (v < 0) {
v = CueUtil.FEATURE_DISABLED;
}
getJdbcTemplate().update(
"UPDATE job_resource SET int_max_slots=? WHERE "
+ "pk_job IN (SELECT pk_job FROM job WHERE pk_folder=?)",
v, g.getGroupId());
}

@Override
public void updateMaxSlots(JobInterface j, int v) {
// Slots are whole counts: -1 unlimited, 0 reject-all, N cap.
if (v < 0) {
v = CueUtil.FEATURE_DISABLED;
}
getJdbcTemplate().update("UPDATE job_resource SET int_max_slots=? WHERE pk_job=?", v,
j.getJobId());

if (accountingNotifier.isEnabled() && showDao.isSchedulerManaged(j.getShowId())) {
accountingNotifier.notifyJobMaxSlots(j.getJobId(), v);
}
}

@Override
public void updateMinGpus(GroupInterface g, int v) {
getJdbcTemplate().update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ public LayerInterface getLayer(String id) {
+ "int_gpu_mem_min, "
+ "str_services, "
+ "int_timeout,"
+ "int_timeout_llu "
+ "int_timeout_llu, "
+ "int_slots_required "
+ ") "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
// spotless:on

@Override
Expand All @@ -332,7 +333,7 @@ public void insertLayerDetail(LayerDetail l) {
l.chunkSize, l.dispatchOrder, StringUtils.join(l.tags, " | "), l.type.toString(),
l.minimumCores, l.maximumCores, l.isThreadable, l.minimumMemory, l.minimumGpus,
l.maximumGpus, l.minimumGpuMemory, StringUtils.join(l.services, ","), l.timeout,
l.timeout_llu);
l.timeout_llu, l.slotsRequired);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public CachedJobWhiteboardMapper(NestedJobWhiteboardMapper result) {
+ "job_resource.int_min_cores, "
+ "job_resource.int_min_gpus, "
+ "job_resource.int_max_cores, "
+ "job_resource.int_max_slots, "
+ "job_resource.int_max_gpus, "
+ "job_mem.int_max_rss, "
+ "job_mem.int_max_pss "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public boolean verifyRunningProc(String procId, String frameId) {
+ "WHERE "
+ "pk_proc=? "
+ "RETURNING int_cores_reserved, int_mem_reserved, "
+ "int_gpus_reserved, int_gpu_mem_reserved";
+ "int_gpus_reserved, int_gpu_mem_reserved, int_slots_reserved";
// spotless:on

public boolean deleteVirtualProc(VirtualProc proc) {
Expand All @@ -117,6 +117,7 @@ public boolean deleteVirtualProc(VirtualProc proc) {
proc.memoryReserved = ((Number) result.get("int_mem_reserved")).longValue();
proc.gpusReserved = ((Number) result.get("int_gpus_reserved")).intValue();
proc.gpuMemoryReserved = ((Number) result.get("int_gpu_mem_reserved")).longValue();
proc.slotsReserved = ((Number) result.get("int_slots_reserved")).intValue();
} catch (EmptyResultDataAccessException e) {
logger.info("failed to delete " + proc + " , proc does not exist.");
return false;
Expand Down Expand Up @@ -341,6 +342,7 @@ public VirtualProc mapRow(ResultSet rs, int rowNum) throws SQLException {
proc.memoryReserved = rs.getLong("int_mem_reserved");
proc.memoryMax = rs.getLong("int_mem_max_used");
proc.gpusReserved = rs.getInt("int_gpus_reserved");
proc.slotsReserved = rs.getInt("int_slots_reserved");
proc.gpuMemoryReserved = rs.getLong("int_gpu_mem_reserved");
proc.gpuMemoryMax = rs.getLong("int_gpu_mem_max_used");
proc.virtualMemoryMax = rs.getLong("int_virt_max_used");
Expand Down Expand Up @@ -370,6 +372,7 @@ public VirtualProc mapRow(ResultSet rs, int rowNum) throws SQLException {
+ "host.pk_alloc, "
+ "alloc.pk_facility,"
+ "proc.int_cores_reserved,"
+ "proc.int_slots_reserved,"
+ "proc.int_mem_reserved,"
+ "proc.int_mem_max_used,"
+ "proc.int_mem_used,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,19 @@ public void updateSubscriptionBurst(SubscriptionInterface sub, int size) {
size);
}
}

@Override
public void updateSubscriptionMaxSlots(SubscriptionInterface sub, int maxSlots) {
// Slots are whole counts: -1 unlimited, 0 reject-all, N cap.
if (maxSlots < 0) {
maxSlots = -1;
}
getJdbcTemplate().update("UPDATE subscription SET int_max_slots=? WHERE pk_subscription=?",
maxSlots, sub.getSubscriptionId());

if (accountingNotifier.isEnabled() && showDao.isSchedulerManaged(sub.getShowId())) {
accountingNotifier.notifySubscriptionMaxSlots(sub.getShowId(), sub.getAllocationId(),
maxSlots);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,8 @@ public static Host.Builder mapHostBuilder(ResultSet rs) throws SQLException {
builder.setLockState(LockState.valueOf(SqlUtil.getString(rs, "str_lock_state")));
builder.setHasComment(rs.getBoolean("b_comment"));
builder.setThreadMode(ThreadMode.values()[rs.getInt("int_thread_mode")]);
builder.setConcurrentSlotsLimit(rs.getInt("int_concurrent_slots_limit"));
builder.setIdleSlots(rs.getInt("int_slots_idle"));
builder.setOs(SqlUtil.getString(rs, "str_os"));

String tags = SqlUtil.getString(rs, "str_tags");
Expand Down Expand Up @@ -1074,7 +1076,7 @@ public Group mapRow(ResultSet rs, int rowNum) throws SQLException {
.setMaxCores(Convert.coreUnitsToCores(rs.getInt("int_max_cores")))
.setMinCores(Convert.coreUnitsToCores(rs.getInt("int_min_cores")))
.setMaxGpus(rs.getInt("int_max_gpus")).setMinGpus(rs.getInt("int_min_gpus"))
.setLevel(rs.getInt("int_level"))
.setMaxSlots(rs.getInt("int_max_slots")).setLevel(rs.getInt("int_level"))
.setParentId(SqlUtil.getString(rs, "pk_parent_folder")).setGroupStats(stats)
.build();
}
Expand All @@ -1087,6 +1089,7 @@ public Job mapRow(ResultSet rs, int rowNum) throws SQLException {
.setMaxCores(Convert.coreUnitsToCores(rs.getInt("int_max_cores")))
.setMinCores(Convert.coreUnitsToCores(rs.getInt("int_min_cores")))
.setMaxGpus(rs.getInt("int_max_gpus")).setMinGpus(rs.getInt("int_min_gpus"))
.setMaxSlots(rs.getInt("int_max_slots"))
.setName(SqlUtil.getString(rs, "str_name"))
.setPriority(rs.getInt("int_priority"))
.setShot(SqlUtil.getString(rs, "str_shot"))
Expand Down Expand Up @@ -1282,6 +1285,7 @@ public Subscription mapRow(ResultSet rs, int rowNum) throws SQLException {
.setBurst(rs.getInt("int_burst")).setName(rs.getString("name"))
.setReservedCores(rs.getInt("int_cores"))
.setReservedGpus(rs.getInt("int_gpus")).setSize(rs.getInt("int_size"))
.setMaxSlots(rs.getInt("int_max_slots"))
.setAllocationName(rs.getString("alloc_name"))
.setShowName(rs.getString("show_name"))
.setFacility(rs.getString("facility_name")).build();
Expand Down Expand Up @@ -1869,6 +1873,7 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
+ "folder.int_job_max_cores,"
+ "folder_resource.int_min_cores,"
+ "folder_resource.int_max_cores,"
+ "folder_resource.int_max_slots,"
+ "folder.int_job_min_gpus,"
+ "folder.int_job_max_gpus,"
+ "folder_resource.int_min_gpus,"
Expand Down Expand Up @@ -1919,6 +1924,7 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
+ "job.pk_job,"
+ "job.str_log_dir,"
+ "job_resource.int_max_cores,"
+ "job_resource.int_max_slots,"
+ "job_resource.int_min_cores,"
+ "job_resource.int_max_gpus,"
+ "job_resource.int_min_gpus,"
Expand Down Expand Up @@ -2220,6 +2226,12 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
+ "host.str_lock_state,"
+ "host.b_comment,"
+ "host.int_thread_mode,"
+ "host.int_concurrent_slots_limit,"
+ "CASE WHEN host.int_concurrent_slots_limit > 0 THEN "
+ "(host.int_concurrent_slots_limit - COALESCE("
+ "(SELECT SUM(proc.int_slots_reserved) FROM proc "
+ "WHERE proc.pk_host = host.pk_host), 0)) "
+ "ELSE -1 END AS int_slots_idle,"
+ "host_stat.str_os,"
+ "host_stat.int_mem_total,"
+ "host_stat.int_mem_free,"
Expand Down Expand Up @@ -2268,6 +2280,7 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
+ "subscription.pk_subscription, "
+ "(alloc.str_name || '.' || show.str_name) AS name, "
+ "subscription.int_burst, "
+ "subscription.int_max_slots, "
+ "subscription.int_size, "
+ "subscription.int_cores, "
+ "subscription.int_gpus, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
import com.imageworks.spcue.grpc.job.GroupSetGroupResponse;
import com.imageworks.spcue.grpc.job.GroupSetMaxCoresRequest;
import com.imageworks.spcue.grpc.job.GroupSetMaxCoresResponse;
import com.imageworks.spcue.grpc.job.GroupSetMaxSlotsRequest;
import com.imageworks.spcue.grpc.job.GroupSetMaxSlotsResponse;
import com.imageworks.spcue.grpc.job.GroupSetMinCoresRequest;
import com.imageworks.spcue.grpc.job.GroupSetMinCoresResponse;
import com.imageworks.spcue.grpc.job.GroupSetMaxGpusRequest;
Expand Down Expand Up @@ -273,6 +275,16 @@ public void setMaxCores(GroupSetMaxCoresRequest request,
responseObserver.onCompleted();
}

@Override
public void setMaxSlots(GroupSetMaxSlotsRequest request,
StreamObserver<GroupSetMaxSlotsResponse> responseObserver) {
GroupInterface group = getGroupInterface(request.getGroup());
// Slots are whole counts, no core-unit conversion.
groupManager.setGroupMaxSlots(group, request.getMaxSlots());
responseObserver.onNext(GroupSetMaxSlotsResponse.newBuilder().build());
responseObserver.onCompleted();
}

@Override
public void setMinCores(GroupSetMinCoresRequest request,
StreamObserver<GroupSetMinCoresResponse> responseObserver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
import com.imageworks.spcue.grpc.host.HostSetHardwareStateResponse;
import com.imageworks.spcue.grpc.host.HostSetOsRequest;
import com.imageworks.spcue.grpc.host.HostSetOsResponse;
import com.imageworks.spcue.grpc.host.HostSetConcurrentSlotsLimitRequest;
import com.imageworks.spcue.grpc.host.HostSetConcurrentSlotsLimitResponse;
import com.imageworks.spcue.grpc.host.HostSetThreadModeRequest;
import com.imageworks.spcue.grpc.host.HostSetThreadModeResponse;
import com.imageworks.spcue.grpc.host.HostUnlockRequest;
Expand Down Expand Up @@ -264,6 +266,15 @@ public void setThreadMode(HostSetThreadModeRequest request,
responseObserver.onCompleted();
}

@Override
public void setConcurrentSlotsLimit(HostSetConcurrentSlotsLimitRequest request,
StreamObserver<HostSetConcurrentSlotsLimitResponse> responseObserver) {
HostInterface host = getHostInterface(request.getHost());
hostDao.updateConcurrentSlotsLimit(host, request.getConcurrentSlotsLimit());
responseObserver.onNext(HostSetConcurrentSlotsLimitResponse.newBuilder().build());
responseObserver.onCompleted();
}

@Override
public void setHardwareState(HostSetHardwareStateRequest request,
StreamObserver<HostSetHardwareStateResponse> responseObserver) {
Expand Down
Loading
Loading