ahahaha-luo opened a new issue, #71185: URL: https://github.com/apache/doris/issues/71185
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version Doris 4.1.3 4.1.3 profile version: doris-4.1.3-rc02-eaaab213c84 Comparison version: Doris 2.1.11 2.1.11 profile version: doris-2.1.11-rc01-97b77e6cda ### What's Wrong? We observed a cold-query performance regression when querying a partitioned Hive external table. Both versions were tested on the same physical machine with the same table and equivalent data. The query produced 32 parallel scan instances and scanned 93 files in both versions. Profile comparison: Doris 4.1.3: - Total: 1436 ms - Plan Time: 1308 ms - Get Partitions: 810 ms - Get Partition Files: 11 ms - Parallel scan instances: 32 - File count: 93 Doris 2.1.11: - Total: 174 ms - Plan Time: 54 ms - Get Partitions: 31 ms - Get Partition Files: 11 ms - Parallel scan instances: 32 - File count: 93 The primary difference is in Get Partitions. Get Partition Files, file count, scan instances, and the amount of scanned data are effectively identical. In Doris 2.1.11, HiveMetaStoreCache uses: partitionCache.getAll(keys) This invokes Caffeine CacheLoader.loadAll, then HiveMetaStoreCache.loadPartitions, and finally one Hive Metastore getPartitionsByNames request. In Doris 4.1.3, HiveExternalMetaCache currently uses: keys.stream() .map(partitionEntry::get) .collect(Collectors.toList()); On cache misses, each key enters MetaCacheEntry.get and HiveExternalMetaCache.loadPartition, resulting in one HMS getPartition request per partition. This makes multiple cold partition cache misses execute serially. In our profile, the measured 810 ms is consistent with multiple serial HMS RPCs, approximately 25 ms per partition. Could maintainers clarify whether this change was intentional during the external meta cache framework refactor in #60937? If it was intentional, what mechanism is expected to replace the previous bulk loadAll/getPartitionsByNames behavior? If it was not intentional, would a PR restoring the batch path through the unified MetaCacheEntry framework be acceptable? ### What You Expected? For multiple Hive partition cache misses, Doris 4.1.3 should preserve the batch-loading behavior available in 2.1.11: 1. Return cache hits directly. 2. Collect only cache-miss partition keys. 3. Load them with one or several bounded getPartitionsByNames requests. 4. Write the results back to the partition cache. 5. Preserve input ordering, invalidation semantics, and error handling. The original bulk design can be seen in: - #21562: use getPartitionsByNames to retrieve Hive partitions - #60937: unified external meta cache framework ### How to Reproduce? 1. Create a partitioned Hive external table. 2. Make sure the FE partition metadata cache is cold. 3. Enable the profile: SET enable_profile = true; SET profile_level = 2; 4. Run: SELECT COUNT(*) FROM <hive_catalog>.<database>.<table>; 5. Get the query ID: SELECT last_query_id(); 6. View the profile: SHOW QUERY PROFILE "/<query_id>"; 7. Repeat the same test with Doris 4.1.3 and Doris 2.1.11 using the same table and a similar partition count. Observed result for the cold query: Doris 4.1.3: Get Partitions = 810 ms Get Partition Files = 11 ms Doris 2.1.11: Get Partitions = 31 ms Get Partition Files = 11 ms I will attach redacted profile files for both versions. ### Anything Else? Related implementation history: - #60937 unified the external meta cache framework and introduced HiveExternalMetaCache + MetaCacheEntry. - #21562 added getPartitionsByNames batch loading in the previous HiveMetaStoreCache implementation. - #21471 added concurrent batch loading for file cache misses. The 4.1.3 implementation still contains HiveExternalMetaCache.loadPartitions, but the withCache=true path does not use it for multiple misses. One possible approach is to add a bulk-loader API to MetaCacheEntry, for example: partitionEntry.getAllByBulkLoader( keys, this::loadPartitionsInBatches) This would allow multiple partition metadata cache misses to use one or several getPartitionsByNames requests while preserving the existing cache invalidation behavior. I am willing to submit a PR if the community agrees with the direction. ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
