Skip to content

Commit

Permalink
Fix garbage collection (#1119)
Browse files Browse the repository at this point in the history
Co-authored-by: ilan-gold <[email protected]>
Co-authored-by: Philipp A. <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent 9918044 commit d51f84c
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 289 deletions.
33 changes: 33 additions & 0 deletions benchmarks/benchmarks/anndata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

import tracemalloc

import numpy as np

from .utils import gen_adata


class GarbargeCollectionSuite:
runs = 10

# custom because `memory_profiler` is a line-by-line profiler (also: https://github.com/pythonprofilers/memory_profiler/issues/402)
def track_peakmem_garbage_collection(self, *_):
def display_top(snapshot, key_type="lineno"):
snapshot = snapshot.filter_traces(
(
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
tracemalloc.Filter(False, "<unknown>"),
)
)
top_stats = snapshot.statistics(key_type)
total = sum(stat.size for stat in top_stats)
return total

total = np.zeros(self.runs)
tracemalloc.start()
for i in range(self.runs):
data = gen_adata(10000, 10000, "X-csc") # noqa: F841
snapshot = tracemalloc.take_snapshot()
total[i] = display_top(snapshot)
tracemalloc.stop()
return max(total)
4 changes: 2 additions & 2 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.. autosummary::
:toctree: .
{% for item in attributes %}
~{{ fullname }}.{{ item }}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
Expand All @@ -26,7 +26,7 @@
:toctree: .
{% for item in methods %}
{%- if item != '__init__' %}
~{{ fullname }}.{{ item }}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# default settings
templates_path = ["_templates"]
html_static_path = ["_static"]
source_suffix = [".rst", ".md"]
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
master_doc = "index"
default_role = "literal"
exclude_patterns = [
Expand Down
Loading

0 comments on commit d51f84c

Please sign in to comment.