Skip to content

Commit

Permalink
Add GPU encoder/decoder utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Jan 21, 2025
1 parent 292df98 commit daa6a18
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/antmedia/rest/RestServiceBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ public static Version getSoftwareVersion() {

version.setVersionType(isEnterprise() ? RestServiceBase.ENTERPRISE_EDITION : RestServiceBase.COMMUNITY_EDITION);

logger.info("Version Name {} Version Type {}", version.getVersionName(), version.getVersionType());
logger.debug("Version Name {} Version Type {}", version.getVersionName(), version.getVersionType());
return version;
}

Expand Down
44 changes: 43 additions & 1 deletion src/main/java/io/antmedia/statistic/GPUUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import static org.bytedeco.cuda.global.nvml.nvmlDeviceGetHandleByIndex_v2;
import static org.bytedeco.cuda.global.nvml.nvmlDeviceGetMemoryInfo;
import static org.bytedeco.cuda.global.nvml.nvmlDeviceGetName;
import static org.bytedeco.cuda.global.nvml.nvmlDeviceGetUtilizationRates;
import static org.bytedeco.cuda.global.nvml.*;

import static org.bytedeco.cuda.global.nvml.nvmlInit_v2;

import org.bytedeco.cuda.global.nvml;
Expand Down Expand Up @@ -123,6 +124,7 @@ private nvmlUtilization_t getUtilization(int deviceNo) {
}
return null;
}



public MemoryStatus getMemoryStatus(int deviceNo) {
Expand All @@ -136,6 +138,46 @@ public MemoryStatus getMemoryStatus(int deviceNo) {
return null;
}

/**
* Get the encoder utilization of the device
* @param deviceNo
* @return encoder utilization by percentage
*/
public int getEncoderUtilization(int deviceNo) {
nvmlDevice_st device = null;
if ((device = getDevice(deviceNo)) != null)
{
int[] encoderUtilization = new int[1];
int[] samplingPeriod = new int[1];

if (nvmlDeviceGetEncoderUtilization(device, encoderUtilization, samplingPeriod) == NVML_SUCCESS) {
return encoderUtilization[0];
}
}
return -1;
}

/**
* Get the decoder utilization of the device
* @param deviceNo
* @return decoder utilization by percentage
*/
public int getDecoderUtilization(int deviceNo) {
nvmlDevice_st device = null;
if ((device = getDevice(deviceNo)) != null)
{
int[] decoderUtilization = new int[1];
int[] samplingPeriod = new int[1];

if (nvmlDeviceGetDecoderUtilization(device, decoderUtilization, samplingPeriod) == NVML_SUCCESS) {
return decoderUtilization[0];
}
}
return -1;
}



public String getDeviceName(int deviceIndex) {
nvmlDevice_st device = null;
if ((device = getDevice(deviceIndex)) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ public String getStreamAppWar(String installLocation)
boolean threadStarted = false;
boolean breakThread = false;

/**
* Bug fix test
* https://github.com/ant-media/Ant-Media-Server/issues/6933
*/
@Test
public void testRestartServerUnderHttpLoad() {

Expand Down

0 comments on commit daa6a18

Please sign in to comment.