mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Improve log messages in text_entries and memory leak unit test
This commit is contained in:
parent
38f24a037d
commit
a08b152358
2 changed files with 4 additions and 2 deletions
|
@ -93,7 +93,7 @@ class TextToEntries(ABC):
|
|||
|
||||
num_deleted_entries = 0
|
||||
if regenerate:
|
||||
with timer("Prepared dataset for regeneration in", logger):
|
||||
with timer("Cleared existing dataset for regeneration in", logger):
|
||||
logger.debug(f"Deleting all entries for file type {file_type}")
|
||||
num_deleted_entries = EntryAdapters.delete_all_entries(user, file_type)
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ def test_encode_docs_memory_leak():
|
|||
batch_size = 20
|
||||
embeddings_model = EmbeddingsModel()
|
||||
memory_usage_trend = []
|
||||
device = f"{helpers.get_device()}".upper()
|
||||
|
||||
# Act
|
||||
# Encode random strings repeatedly and record memory usage trend
|
||||
|
@ -76,8 +77,9 @@ def test_encode_docs_memory_leak():
|
|||
# Calculate slope of line fitting memory usage history
|
||||
memory_usage_trend = np.array(memory_usage_trend)
|
||||
slope, _, _, _, _ = linregress(np.arange(len(memory_usage_trend)), memory_usage_trend)
|
||||
print(f"Memory usage increased at ~{slope:.2f} MB per iteration on {device}")
|
||||
|
||||
# Assert
|
||||
# If slope is positive memory utilization is increasing
|
||||
# Positive threshold of 2, from observing memory usage trend on MPS vs CPU device
|
||||
assert slope < 2, f"Memory usage increasing at ~{slope:.2f} MB per iteration"
|
||||
assert slope < 2, f"Memory leak suspected on {device}. Memory usage increased at ~{slope:.2f} MB per iteration"
|
||||
|
|
Loading…
Reference in a new issue