-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add manifest file caching support for Iceberg Hive Metastore catalog #22376
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
.../src/main/java/io/trino/plugin/iceberg/catalog/hms/IcebergHiveMetastoreCatalogConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.plugin.iceberg.catalog.hms; | ||
|
|
||
| import io.airlift.configuration.Config; | ||
| import io.airlift.configuration.ConfigDescription; | ||
| import io.airlift.units.DataSize; | ||
| import io.airlift.units.Duration; | ||
|
|
||
| import static io.airlift.units.DataSize.Unit.BYTE; | ||
| import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_EXPIRATION_INTERVAL_MS_DEFAULT; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_MAX_CONTENT_LENGTH_DEFAULT; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_MAX_TOTAL_BYTES_DEFAULT; | ||
|
|
||
| public class IcebergHiveMetastoreCatalogConfig | ||
| { | ||
| private boolean manifestCachingEnabled; | ||
| private DataSize maxManifestCacheSize = DataSize.of(IO_MANIFEST_CACHE_MAX_TOTAL_BYTES_DEFAULT, BYTE); | ||
| private Duration manifestCacheExpireDuration = new Duration(IO_MANIFEST_CACHE_EXPIRATION_INTERVAL_MS_DEFAULT, MILLISECONDS); | ||
| private DataSize manifestCacheMaxContentLength = DataSize.of(IO_MANIFEST_CACHE_MAX_CONTENT_LENGTH_DEFAULT, BYTE); | ||
|
|
||
| public boolean isManifestCachingEnabled() | ||
| { | ||
| return manifestCachingEnabled; | ||
| } | ||
|
|
||
| @Config("iceberg.hive.manifest.cache-enabled") | ||
| @ConfigDescription("Enable/disable the manifest caching feature in Hive Metastore catalog") | ||
| public IcebergHiveMetastoreCatalogConfig setManifestCachingEnabled(boolean manifestCachingEnabled) | ||
| { | ||
| this.manifestCachingEnabled = manifestCachingEnabled; | ||
| return this; | ||
| } | ||
|
|
||
| public DataSize getMaxManifestCacheSize() | ||
| { | ||
| return maxManifestCacheSize; | ||
| } | ||
|
|
||
| @Config("iceberg.hive.manifest.cache.max-total-size") | ||
| @ConfigDescription("Maximum total amount to cache in the manifest cache of Hive Metastore catalog") | ||
| public IcebergHiveMetastoreCatalogConfig setMaxManifestCacheSize(DataSize maxManifestCacheSize) | ||
| { | ||
| this.maxManifestCacheSize = maxManifestCacheSize; | ||
| return this; | ||
| } | ||
|
|
||
| public Duration getManifestCacheExpireDuration() | ||
| { | ||
| return manifestCacheExpireDuration; | ||
| } | ||
|
|
||
| @Config("iceberg.hive.manifest.cache.expiration-interval-duration") | ||
| @ConfigDescription("Maximum duration for which an entry stays in the manifest cache of Hive Metastore catalog") | ||
| public IcebergHiveMetastoreCatalogConfig setManifestCacheExpireDuration(Duration manifestCacheExpireDuration) | ||
| { | ||
| this.manifestCacheExpireDuration = manifestCacheExpireDuration; | ||
| return this; | ||
| } | ||
|
|
||
| public DataSize getManifestCacheMaxContentLength() | ||
| { | ||
| return manifestCacheMaxContentLength; | ||
| } | ||
|
|
||
| @Config("iceberg.hive.manifest.cache.max-content-length") | ||
| @ConfigDescription("Maximum length of a manifest file to be considered for caching in Hive Metastore catalog") | ||
| public IcebergHiveMetastoreCatalogConfig setManifestCacheMaxContentLength(DataSize manifestCacheMaxContentLength) | ||
| { | ||
| this.manifestCacheMaxContentLength = manifestCacheMaxContentLength; | ||
| return this; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
.../test/java/io/trino/plugin/iceberg/catalog/hms/TestIcebergHiveMetastoreCatalogConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.plugin.iceberg.catalog.hms; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import io.airlift.units.DataSize; | ||
| import io.airlift.units.Duration; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping; | ||
| import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults; | ||
| import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults; | ||
| import static io.airlift.units.DataSize.Unit.BYTE; | ||
| import static io.airlift.units.DataSize.Unit.GIGABYTE; | ||
| import static io.airlift.units.DataSize.Unit.MEGABYTE; | ||
| import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
| import static java.util.concurrent.TimeUnit.MINUTES; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_EXPIRATION_INTERVAL_MS_DEFAULT; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_MAX_CONTENT_LENGTH_DEFAULT; | ||
| import static org.apache.iceberg.CatalogProperties.IO_MANIFEST_CACHE_MAX_TOTAL_BYTES_DEFAULT; | ||
|
|
||
| public class TestIcebergHiveMetastoreCatalogConfig | ||
| { | ||
| @Test | ||
| public void testDefaults() | ||
| { | ||
| assertRecordedDefaults(recordDefaults(IcebergHiveMetastoreCatalogConfig.class) | ||
| .setManifestCachingEnabled(false) | ||
| .setMaxManifestCacheSize(DataSize.of(IO_MANIFEST_CACHE_MAX_TOTAL_BYTES_DEFAULT, BYTE)) | ||
| .setManifestCacheExpireDuration(new Duration(IO_MANIFEST_CACHE_EXPIRATION_INTERVAL_MS_DEFAULT, MILLISECONDS)) | ||
| .setManifestCacheMaxContentLength(DataSize.of(IO_MANIFEST_CACHE_MAX_CONTENT_LENGTH_DEFAULT, BYTE))); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExplicitPropertyMappings() | ||
| { | ||
| Map<String, String> properties = ImmutableMap.<String, String>builder() | ||
| .put("iceberg.hive.manifest.cache-enabled", "true") | ||
| .put("iceberg.hive.manifest.cache.max-total-size", "1GB") | ||
| .put("iceberg.hive.manifest.cache.expiration-interval-duration", "10m") | ||
| .put("iceberg.hive.manifest.cache.max-content-length", "10MB") | ||
| .buildOrThrow(); | ||
|
|
||
| IcebergHiveMetastoreCatalogConfig expected = new IcebergHiveMetastoreCatalogConfig() | ||
| .setManifestCachingEnabled(true) | ||
| .setMaxManifestCacheSize(DataSize.of(1, GIGABYTE)) | ||
| .setManifestCacheExpireDuration(new Duration(10, MINUTES)) | ||
| .setManifestCacheMaxContentLength(DataSize.of(10, MEGABYTE)); | ||
|
|
||
| assertFullMapping(properties, expected); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is configuring
org.apache.iceberg.ManifestFiles#CONTENT_CACHES, right?the cache is keyed by
FileIOand ourForwardingFileIois typically short-lived. how effective is this caching?cc @alexjo2144 @electrum
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in one of our production environments, a big sql which was planned for 12s has been reduced to 8s~
In our internal implementation, we also used a Caffeine cache with the key
CatalogTypeand the valueFileIoto make aForwardingFileIolive longer, i can also add relevant codes to our PRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 12s -> 8s improvement -- was it with or without fileio caching?
what would the numbers be if we don't do this PR and instead enable filesystem caching that we already have in trino?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findepi the 12s -> 8s improvement was with fileio/manifest caching.
Sorry our newest production environment is 423, so i couldn't test the performance about filesystem caching, but i saw that PrestoDB have
manifest cachingandfilesystem cachingboth, so i thought that they may not conflict with each other~ The metadata caching in memory is also faster than metadata caching in disks in most cases.Thank you for your advice, I have modified some codes accordingly, please review again when you have time~ The CICD error seems not related to our PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
before merging this PR, we should understand what's the level of improvement that it brings (in isolation).
cc @sopel39 @raunaqmorarka