I use XGBoost JVM Package with Scala API inside my Scala project: xgboost4j_2.11-1.1.2
I load trained model beforehand and then I call only 1 function Booster.predict()
on the one dimensional matrix (input: Array[Float]). Here’s the code example:
Try {
val dMatrix = new DMatrix(input, 1, 19)
val prediction = booster.predict(dMatrix)
prediction.headOption.flatMap(_.headOption)
} match {
case Success(predictedRate) =>
predictedRate
case Failure(e) =>
logger.error(s"Failed to predict, model version: ", e)
metricsClient.incrementCounter("rate_predictor_failure", 'exception -> e.getClass.getSimpleName)
None
}
When I run this function 100k times in a loop and measure the running time of this code I see that the running time slightly goes up for every iteration. So, if I start with 1ms and less than after 40k iterations I get to 11-12 ms and it even goes up.
In case of our system this is considered to be a bad performance. Is it a known issue? Is there any way to speed the prediction time up? Am I missing anything here?
Thanks in advance!
UPD: I see the same bad performance if I use version 1.4.1, too.