This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new c244aadcf IMPALA-12402: Make CatalogdMetaProvider's cache concurrency 
level configurable
c244aadcf is described below

commit c244aadcf367360e52807a84e7fba8b6237651fd
Author: maxwellguo <[email protected]>
AuthorDate: Thu Aug 31 14:40:24 2023 +0800

    IMPALA-12402: Make CatalogdMetaProvider's cache concurrency level 
configurable
    
    The local CatalogMetaProvider's cache_ need to doing some loading
    process with the default cache concurrency level of 4, when the
    table number is very big, the loading process will cost much time,
    in that case the restart process will cost much time too, so we make
    cache concurrency level parameter configurable.
    
    Change-Id: I8e3c10660e371498c2edc1eb8d235b7b8ca170c9
    Reviewed-on: http://gerrit.cloudera.org:8080/20443
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Quanlong Huang <[email protected]>
---
 be/src/runtime/exec-env.cc                                    |  4 ++++
 be/src/util/backend-gflag-util.cc                             |  3 +++
 common/thrift/BackendGflags.thrift                            |  2 ++
 .../org/apache/impala/catalog/local/CatalogdMetaProvider.java | 11 +++++++++--
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/be/src/runtime/exec-env.cc b/be/src/runtime/exec-env.cc
index a9f3a654d..3931f5f44 100644
--- a/be/src/runtime/exec-env.cc
+++ b/be/src/runtime/exec-env.cc
@@ -123,6 +123,10 @@ DEFINE_int32(local_catalog_max_fetch_retries, 40,
     "If --use_local_catalog is enabled, configures the maximum number of times 
"
     "the frontend retries when fetching a metadata object from the impalad "
     "coordinator's local catalog cache.");
+DEFINE_int32(local_catalog_cache_concurrency_level, 4,
+    "If --use_local_catalog is enabled, configures the local cache's 
concurrency "
+    "level to avoid lock contention, the default value 4 is consistent with 
the "
+    "default value of the original cache.");
 
 DECLARE_int32(state_store_port);
 DECLARE_int32(num_threads_per_core);
diff --git a/be/src/util/backend-gflag-util.cc 
b/be/src/util/backend-gflag-util.cc
index 72fd2471b..aef4304de 100644
--- a/be/src/util/backend-gflag-util.cc
+++ b/be/src/util/backend-gflag-util.cc
@@ -34,6 +34,7 @@ DECLARE_bool(enable_stats_extrapolation);
 DECLARE_bool(use_local_catalog);
 DECLARE_int32(local_catalog_cache_expiration_s);
 DECLARE_int32(local_catalog_cache_mb);
+DECLARE_int32(local_catalog_cache_concurrency_level);
 DECLARE_int32(non_impala_java_vlog);
 DECLARE_int32(num_metadata_loading_threads);
 DECLARE_int32(max_hdfs_partitions_parallel_load);
@@ -291,6 +292,8 @@ Status PopulateThriftBackendGflags(TBackendGflags& cfg) {
   cfg.__set_local_catalog_cache_mb(FLAGS_local_catalog_cache_mb);
   cfg.__set_local_catalog_cache_expiration_s(
     FLAGS_local_catalog_cache_expiration_s);
+  cfg.__set_local_catalog_cache_concurrency_level(
+    FLAGS_local_catalog_cache_concurrency_level);
   cfg.__set_server_name(FLAGS_server_name);
   cfg.__set_kudu_master_hosts(FLAGS_kudu_master_hosts);
   cfg.__set_enable_kudu_impala_hms_check(FLAGS_enable_kudu_impala_hms_check);
diff --git a/common/thrift/BackendGflags.thrift 
b/common/thrift/BackendGflags.thrift
index 0ca30ca4a..919d34255 100644
--- a/common/thrift/BackendGflags.thrift
+++ b/common/thrift/BackendGflags.thrift
@@ -266,4 +266,6 @@ struct TBackendGflags {
   117: required bool enable_json_scanner
 
   118: required double max_filter_error_rate_from_full_scan
+
+  119: required i32 local_catalog_cache_concurrency_level
 }
diff --git 
a/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java 
b/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
index f35832c26..218ffc4d5 100644
--- a/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
+++ b/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
@@ -363,12 +363,19 @@ public class CatalogdMetaProvider implements MetaProvider 
{
       cacheSizeBytes = flags.local_catalog_cache_mb * 1024 * 1024;
     }
     int expirationSecs = flags.local_catalog_cache_expiration_s;
-    LOG.info("Metadata cache configuration: capacity={} MB, expiration={} sec",
-        cacheSizeBytes/1024/1024, expirationSecs);
+    int concurrencyLevel = flags.local_catalog_cache_concurrency_level;
+    if (concurrencyLevel <= 0) {
+      // 4 is the default value of the local cache
+      concurrencyLevel = 4;
+    }
+    LOG.info("Metadata cache configuration: capacity={} MB, expiration={} sec, 
" +
+        "concurrencyLevel={}", cacheSizeBytes/1024/1024, expirationSecs,
+        concurrencyLevel);
 
     // TODO(todd) add end-to-end test cases which stress cache eviction (both 
time
     // and size-triggered) and make sure results are still correct.
     cache_ = CacheBuilder.newBuilder()
+        .concurrencyLevel(concurrencyLevel)
         .maximumWeight(cacheSizeBytes)
         .expireAfterAccess(expirationSecs, TimeUnit.SECONDS)
         .weigher(new SizeOfWeigher(

Reply via email to