Skip to content

Commit c53579c

Browse files
committed
[BUG]: Make sure hnsw_cache_size is never zero to avoid seg fault
1 parent 7202f83 commit c53579c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

chromadb/api/rust.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ def __init__(self, system: System):
7575
max_file_handles = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
7676
else:
7777
max_file_handles = ctypes.windll.msvcrt._getmaxstdio() # type: ignore
78-
self.hnsw_cache_size = (
79-
max_file_handles
80-
# This is integer division in Python 3, and not a comment.
81-
# Each HNSW index has 4 data files and 1 metadata file
82-
// 5
83-
)
78+
# Calculate cache size with a minimum value of 1 to avoid segmentation fault
79+
self.hnsw_cache_size = max(1, max_file_handles // 5)
8480

8581
@override
8682
def start(self) -> None:

0 commit comments

Comments
 (0)