Skip to content

Commit 468fd12

Browse files
committed
Clarify manifest cache reuse
1 parent 38f411e commit 468fd12

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

pyiceberg/manifest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,9 @@ def __hash__(self) -> int:
892892
return hash(self.manifest_path)
893893

894894

895-
# Global cache for ManifestFile objects, keyed by manifest_path. This
896-
# deduplicates ManifestFile objects across manifest lists, which commonly share
897-
# manifests after append operations.
895+
# Global cache for ManifestFile objects, keyed by manifest_path. This reuses
896+
# ManifestFile objects across manifest lists, which commonly share manifests
897+
# after append operations.
898898
class _ManifestCache:
899899
DEFAULT_SIZE = 128
900900

@@ -921,7 +921,7 @@ def clear(self) -> None:
921921
if self._cache is not None:
922922
self._cache.clear()
923923

924-
def deduplicate(self, manifest_files: list[ManifestFile]) -> tuple[ManifestFile, ...]:
924+
def reuse_cached(self, manifest_files: list[ManifestFile]) -> tuple[ManifestFile, ...]:
925925
if self._cache is None:
926926
return tuple(manifest_files)
927927

@@ -955,7 +955,7 @@ def clear_manifest_cache() -> None:
955955

956956

957957
def _manifests(io: FileIO, manifest_list: str) -> tuple[ManifestFile, ...]:
958-
"""Read manifests from a manifest list, deduplicating ManifestFile objects via cache.
958+
"""Read manifests from a manifest list, reusing cached ManifestFile objects.
959959
960960
Caches individual ManifestFile objects by manifest_path. This is memory-efficient
961961
because consecutive manifest lists typically share most of their manifests:
@@ -981,7 +981,7 @@ def _manifests(io: FileIO, manifest_list: str) -> tuple[ManifestFile, ...]:
981981
file = io.new_input(manifest_list)
982982
manifest_files = list(read_manifest_list(file))
983983

984-
return _manifest_cache.deduplicate(manifest_files)
984+
return _manifest_cache.reuse_cached(manifest_files)
985985

986986

987987
def read_manifest_list(input_file: InputFile) -> Iterator[ManifestFile]:

tests/benchmark/test_memory_benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def clear_caches() -> None:
7373
def test_manifest_cache_memory_growth(memory_catalog: InMemoryCatalog) -> None:
7474
"""Benchmark memory growth of manifest cache during repeated appends.
7575
76-
This test reproduces the issue from GitHub #2325 where each append creates
77-
a new manifest list entry in the cache, causing memory to grow.
76+
This test reproduces the issue from GitHub #2325 where the old cache stored
77+
each manifest list result, causing memory to grow.
7878
7979
With the old caching strategy (tuple per manifest list), memory grew as O(N²).
8080
With the new strategy (individual ManifestFile objects), memory grows as O(N).

0 commit comments

Comments
 (0)