Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-7385][CH] Add some config parameters to constrol the cache size for the mergetree parts #7386

Merged
merged 1 commit into from
Sep 29, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ object CHBackendSettings extends BackendSettingsApi with Logging {

val GLUTEN_AQE_PROPAGATEEMPTY: String = CHConf.prefixOf("aqe.propagate.empty.relation")

val GLUTEN_CLICKHOUSE_DELTA_SCAN_CACHE_SIZE: String = CHConf.prefixOf("deltascan.cache.size")
val GLUTEN_CLICKHOUSE_ADDFILES_TO_MTPS_CACHE_SIZE: String =
CHConf.prefixOf("addfiles.to.mtps.cache.size")
val GLUTEN_CLICKHOUSE_TABLE_PATH_TO_MTPS_CACHE_SIZE: String =
CHConf.prefixOf("table.path.to.mtps.cache.size")

def affinityMode: String = {
SparkEnv.get.conf
.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package org.apache.spark.sql.delta

import org.apache.gluten.backendsapi.clickhouse.CHBackendSettings

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.catalyst.expressions.{AttributeReference, BindReferences, Expression, Predicate}
import org.apache.spark.sql.delta.actions.AddFile
import org.apache.spark.sql.delta.stats.DeltaScan
Expand Down Expand Up @@ -82,14 +85,20 @@ case class FilterExprsAsKey(

object ClickhouseSnapshot {
val deltaScanCache: Cache[FilterExprsAsKey, DeltaScan] = CacheBuilder.newBuilder
.maximumSize(100)
.expireAfterAccess(3600L, TimeUnit.SECONDS)
.maximumSize(
SparkSession.getActiveSession.get.conf
.get(CHBackendSettings.GLUTEN_CLICKHOUSE_DELTA_SCAN_CACHE_SIZE, "10000")
.toLong)
.expireAfterAccess(7200L, TimeUnit.SECONDS)
.recordStats()
.build()

val addFileToAddMTPCache: LoadingCache[AddFileAsKey, AddMergeTreeParts] = CacheBuilder.newBuilder
.maximumSize(1000000)
.expireAfterAccess(3600L, TimeUnit.SECONDS)
.maximumSize(
SparkSession.getActiveSession.get.conf
.get(CHBackendSettings.GLUTEN_CLICKHOUSE_ADDFILES_TO_MTPS_CACHE_SIZE, "1000000")
.toLong)
.expireAfterAccess(7200L, TimeUnit.SECONDS)
.recordStats
.build[AddFileAsKey, AddMergeTreeParts](new CacheLoader[AddFileAsKey, AddMergeTreeParts]() {
@throws[Exception]
Expand All @@ -99,8 +108,11 @@ object ClickhouseSnapshot {
})

val pathToAddMTPCache: Cache[String, AddMergeTreeParts] = CacheBuilder.newBuilder
.maximumSize(1000000)
.expireAfterAccess(3600L, TimeUnit.SECONDS)
.maximumSize(
SparkSession.getActiveSession.get.conf
.get(CHBackendSettings.GLUTEN_CLICKHOUSE_TABLE_PATH_TO_MTPS_CACHE_SIZE, "1000000")
.toLong)
.expireAfterAccess(7200L, TimeUnit.SECONDS)
.recordStats()
.build()

Expand Down
Loading