iemejia commented on code in PR #12400:
URL: https://github.com/apache/gluten/pull/12400#discussion_r3557352470


##########
backends-velox/src/main/scala/org/apache/gluten/config/VeloxConfig.scala:
##########
@@ -530,10 +531,35 @@ object VeloxConfig extends ConfigRegistry {
   val COLUMNAR_VELOX_FILE_HANDLE_CACHE_ENABLED =
     
buildStaticConf("spark.gluten.sql.columnar.backend.velox.fileHandleCacheEnabled")
       .doc(
-        "Disables caching if false. File handle cache should be disabled " +
-          "if files are mutable, i.e. file content may change while file path 
stays the same.")
+        "Enables caching of file handles to avoid repeated open/close overhead 
on remote " +
+          "filesystems. Should be disabled if files are mutable, i.e. file 
content may " +
+          "change while file path stays the same.")
       .booleanConf
-      .createWithDefault(false)
+      .createWithDefault(true)
+
+  val COLUMNAR_VELOX_NUM_CACHE_FILE_HANDLES =
+    
buildStaticConf("spark.gluten.sql.columnar.backend.velox.numCacheFileHandles")
+      .doc(
+        "Maximum number of entries in the file handle cache. Each entry holds 
an open " +
+          "file descriptor (local FS) or connection state (remote FS). Note 
that on " +
+          "local filesystems, high values may approach the OS file descriptor 
limit " +
+          "(ulimit -n). On remote object stores (S3, ABFS, GCS) entries 
represent " +
+          "network connections/sockets rather than per-file OS file 
descriptors, but " +
+          "they can still count toward OS resource limits (ulimit -n).")
+      .intConf
+      .checkValue(_ > 0, "must be a positive number")
+      .createWithDefault(10000)
+
+  val COLUMNAR_VELOX_FILE_HANDLE_EXPIRATION_DURATION_MS =
+    
buildStaticConf("spark.gluten.sql.columnar.backend.velox.fileHandleExpirationDurationMs")
+      .doc(
+        "Expiration time in milliseconds for cached file handles. Handles not 
accessed " +
+          "within this duration are evicted from the cache. This prevents 
stale handles " +
+          "from accumulating (e.g., expired HDFS leases, closed remote 
connections). " +
+          "A value of 0 disables TTL-based eviction.")
+      .timeConf(TimeUnit.MILLISECONDS)
+      .checkValue(_ >= 0, "must be a non-negative number (0 disables TTL-based 
eviction)")
+      .createWithDefault(600000L) // 10 minutes

Review Comment:
   You're right, thanks for pointing to `GlutenConfigUtil.parseConfig` -- it 
calls `readFrom` which applies `timeFromString`, then `.toString` on the 
resulting Long, so native always receives a plain numeric string. We had 
previously reverted to `longConf` based on a wrong assumption about the native 
path. Changed back to `timeConf(TimeUnit.MILLISECONDS)` in 4d2156c63.



##########
ep/build-velox/src/file-handle-cache-ttl.patch:
##########
@@ -0,0 +1,14 @@
+diff --git a/velox/connectors/hive/HiveConnector.cpp 
b/velox/connectors/hive/HiveConnector.cpp
+index abc13acea..861f95c7f 100644
+--- a/velox/connectors/hive/HiveConnector.cpp
++++ b/velox/connectors/hive/HiveConnector.cpp
+@@ -40,7 +40,8 @@ HiveConnector::HiveConnector(
+       fileHandleFactory_(
+           hiveConfig_->isFileHandleCacheEnabled()
+               ? std::make_unique<SimpleLRUCache<FileHandleKey, FileHandle>>(
+-                    hiveConfig_->numCacheFileHandles())
++                    hiveConfig_->numCacheFileHandles(),
++                    hiveConfig_->fileHandleExpirationDurationMs())

Review Comment:
   Already submitted upstream as 
[facebookincubator/velox#18072](https://github.com/facebookincubator/velox/pull/18072).
 The `get-velox.sh` script already has a guard that detects when the patch is 
applied upstream and skips it automatically. Once it's merged upstream, I'll 
submit a follow-up PR to remove the patch from Gluten.



-- 
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]

Reply via email to