hvanhovell commented on code in PR #50013:
URL: https://github.com/apache/spark/pull/50013#discussion_r1968708896
##########
sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLCache.scala:
##########
@@ -21,23 +21,52 @@ import java.util.concurrent.{ConcurrentMap, TimeUnit}
import com.google.common.cache.CacheBuilder
-import org.apache.spark.internal.Logging
+import org.apache.spark.internal.{Logging, LogKeys, MDC}
+import org.apache.spark.ml.Model
import org.apache.spark.ml.util.ConnectHelper
+import org.apache.spark.sql.classic.SparkSession
+import org.apache.spark.sql.connect.config.Connect._
+import org.apache.spark.util.SizeEstimator
/**
* MLCache is for caching ML objects, typically for models and summaries
evaluated by a model.
*/
-private[connect] class MLCache extends Logging {
+private[connect] class MLCache(session: SparkSession) extends Logging {
private val helper = new ConnectHelper()
private val helperID = "______ML_CONNECT_HELPER______"
+ private def conf = session.sessionState.conf
- private val cachedModel: ConcurrentMap[String, Object] = CacheBuilder
- .newBuilder()
- .softValues()
- .maximumSize(MLCache.MAX_CACHED_ITEMS)
- .expireAfterAccess(MLCache.CACHE_TIMEOUT_MINUTE, TimeUnit.MINUTES)
- .build[String, Object]()
- .asMap()
+ private val cachedModel: ConcurrentMap[String, (Object, Long)] = {
+ val builder = CacheBuilder.newBuilder().softValues()
+
+ val cacheWeight = conf.getConf(CONNECT_SESSION_ML_CACHE_TOTAL_ITEM_SIZE)
+ val cacheSize = conf.getConf(CONNECT_SESSION_ML_CACHE_SIZE)
+ val timeOut = conf.getConf(CONNECT_SESSION_ML_CACHE_TIMEOUT)
+
+ if (cacheWeight > 0) {
+ builder
Review Comment:
What is the eviction policy here? LRU?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]