-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix garbage collection #1119
Merged
Merged
Fix garbage collection #1119
Changes from 16 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a9a10af
Make creation of aligned mapping lazy
ivirshup ca0759a
Use weakref for filemanager
ivirshup 92615d8
Merge branch 'main' into remove-backrefs
ilan-gold cb53b77
(chore): add benchmark
ilan-gold 2df03b5
(fix): use right `gen_adata` function
ilan-gold 38d218f
(fix): change name
ilan-gold a9eba7a
(chore): fewer runs
ilan-gold be8ae55
(fix): benchmark test name
ilan-gold 82fc74c
Merge branch 'main' into remove-backrefs
ilan-gold e0bff0e
(fix): return `cls` for `None` obj
ilan-gold ccbdaf3
Merge branch 'remove-backrefs' of https://github.com/ivirshup/anndata…
ilan-gold 6ed9963
(fix): try `track_peakmem`
ilan-gold ce4e2d8
(fix): remove `track_` name
ilan-gold 0c9e563
(fix): docs
ilan-gold c971dfb
(fix): do custom peakmem track
ilan-gold 9e08151
(fix): `n` -> `runs`
ilan-gold c771079
(fix): comment
ilan-gold 9d3caad
(fix): `vals` typing for aligned mappings
ilan-gold eeb8865
(fix): don't use mutable argument
ilan-gold 5267c2d
(fix): change profiler name to `track_peakmem_garbage_collection`
ilan-gold 13d134a
(chore): delete rogue comment
ilan-gold 4dec616
clarify reference use
flying-sheep 5361188
consistency
flying-sheep b61549d
remove boilerplate
flying-sheep 81d5933
Merge branch 'main' into remove-backrefs
ilan-gold 1a85497
add types, undo moves
flying-sheep f750954
Add type hints for properties
flying-sheep ab4cd79
Merge branch 'main' into remove-backrefs
ilan-gold cf4377c
Merge branch 'main' into pr/ivirshup/1119
flying-sheep 48ae69d
fmt
flying-sheep 480b0a4
cleanup
flying-sheep 24b89a0
more fmt
flying-sheep 05ebee9
dedupe and test
flying-sheep 866abbd
Simplify copy
flying-sheep 3595197
Merge branch 'main' into pr/ivirshup/1119
flying-sheep 015d6ad
docs and typing
flying-sheep 3a1a007
fix parent_mapping type
flying-sheep 73fc94c
Fix I
flying-sheep ba61e2b
fix docs
flying-sheep e138fc9
fix 3.9
flying-sheep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||
|
||
# https://github.com/pythonprofilers/memory_profiler/issues/402 and other backend does not pick this up | ||
def track_peakmem_write_compressed(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) |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok @ivirshup @flying-sheep independent of this issue, were you aware that https://pypi.org/project/memory-profiler/ is a line-by-line profiler? I think this is probably not very good for us, no? When I read
get_peakmem
(i.e., the function inutils
we wrote based onmemory_profiler
), I would think that it would really track the literal peak memory, and not the peak over individual line operations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly: https://scverse.zulipchat.com/#narrow/stream/393966-scanpy-anndata-dev/topic/Benchmarking/near/442513634