-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix telemetry cleanup bug (from #800)
* Fix bug where telemetry does not clean up objects when telemetry=false * Add a memory profiler endpoint /memory, disabled by default and enabled through an environment variable
- Loading branch information
Showing
10 changed files
with
192 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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 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 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,8 @@ | ||
from typing import List | ||
|
||
from marqo.base_model import ImmutableStrictBaseModel | ||
|
||
|
||
class MemoryProfile(ImmutableStrictBaseModel): | ||
memory_used: float | ||
stats: List[str] |
This file contains 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,20 @@ | ||
import tracemalloc | ||
|
||
from memory_profiler import memory_usage | ||
|
||
from marqo.core.models.memory_profile import MemoryProfile | ||
|
||
|
||
def get_memory_profile() -> MemoryProfile: | ||
tracemalloc.start() | ||
|
||
snapshot = tracemalloc.take_snapshot() | ||
stats = snapshot.statistics('lineno') | ||
|
||
# Get mem used | ||
mem_used = memory_usage(-1, interval=0.1, timeout=1) | ||
|
||
return MemoryProfile( | ||
memory_used=mem_used[0], | ||
stats=[str(s) for s in stats] | ||
) |
This file contains 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 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 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 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 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
Oops, something went wrong.