-
Notifications
You must be signed in to change notification settings - Fork 19
gc: fix collection fallbacks, shared actions, and heap dumps #1160
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
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
04932b4
gc: report a completed transition from the cranelift and wasm collect…
youknowone 46447ed
gc: answer gc_isenabled before the GC singleton is stored
youknowone 5e2c2f2
gc: drop the repeated summary line from wrap_raw_nodes' doc
youknowone 8b9b825
gc: write the heap dump through an installable host write
youknowone 6eb5fdd
gc: share space actions across execution contexts
youknowone 96f65d7
gc: collect JSON encoder strings
youknowone 0b0d65a
gc: collect JSON decoder strings
youknowone b676483
gc: collect JSON error notes
youknowone 7978c7c
gc: collect JSON encoder chunks
youknowone 59aeffd
gc: collect JSON float keys
youknowone 99d5d1d
gc: collect explicit GenericAlias reprs
youknowone 8b9ca39
gc: collect ContextVar reprs
youknowone ffbccee
gc: collect ContextVar token reprs
youknowone b390e6e
gc: collect structseq reprs
youknowone f81d30f
gc: collect array unicode strings
youknowone 842a4d5
gc: collect explicit array reprs
youknowone 1e35656
gc: collect explicit deque reprs
youknowone 16dcd85
gc: collect explicit SRE pattern reprs
youknowone 739993a
gc: collect explicit SRE match reprs
youknowone c4fcdac
gc: preserve weak proxy str identity
youknowone 1fe1e64
gc: collect unpickled unicode strings
youknowone e82eec4
gc: manage unicode normalization results
youknowone f51a789
gc: collect SimpleNamespace reprs
youknowone affe4a2
gc: collect sre substitution outputs
youknowone 0318f7d
gc: collect sre subject slices
youknowone e0f6471
gc: collect strftime results
youknowone 3290819
gc: collect asctime and ctime results
youknowone 9e98949
gc: collect DirEntry reprs
youknowone 7c4c719
gc: collect memoryview reprs
youknowone d82f02a
gc: collect weakref reprs
youknowone eaf62b0
gc: collect mmap reprs
youknowone f310d67
gc: collect FileIO reprs
youknowone 7e2dddf
gc: collect exception reprs
youknowone 4f967aa
gc: collect exception str results
youknowone c4a7a4d
gc: collect exception group render results
youknowone 1f8aa4b
gc: collect bound method reprs
youknowone 92cbe98
gc: collect super reprs
youknowone 2348898
gc: collect union reprs
youknowone 2ecd54f
gc: collect function reprs
youknowone 2d668fb
gc: collect builtin function reprs
youknowone 1195dfd
ci: skip mmap repr fixture when unavailable
youknowone dd5ef4e
gc: collect getset descriptor reprs
youknowone 088386b
gc: collect member descriptor reprs
youknowone 70682ec
gc: collect method descriptor reprs
youknowone e3f2e81
gc: collect classmethod descriptor reprs
youknowone 044b249
ci: match mmap skip output on Windows
youknowone 80e9453
gc: collect method-wrapper reprs
youknowone f68c5cb
gc: collect type reprs
youknowone fb260d6
gc: collect cell reprs
youknowone 1408a4f
gc: collect generator reprs
youknowone a3b84e4
test: consolidate GC collectability fixtures
youknowone db5be09
gc: consolidate remaining repr collectability coverage
youknowone 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
This file contains hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
This file contains hidden or 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 @@ | ||
| # pyre-check: no-cpython | ||
| # pyre-check: skip-backends=wasm | ||
| # The wasm guest has no OS-thread implementation, while this fixture verifies | ||
| # which native mutator dispatches an object-space GC action. | ||
| import _thread | ||
| import gc | ||
|
|
||
|
|
||
| main_ident = _thread.get_ident() | ||
| callback_idents = [] | ||
| worker_idents = [] | ||
| done = _thread.allocate_lock() | ||
| done.acquire() | ||
|
|
||
|
|
||
| def on_collect(stats): | ||
| callback_idents.append(_thread.get_ident()) | ||
|
|
||
|
|
||
| def worker(): | ||
| worker_idents.append(_thread.get_ident()) | ||
| gc.collect() | ||
| done.release() | ||
|
|
||
|
|
||
| gc.hooks.on_gc_collect = on_collect | ||
| _thread.start_new_thread(worker, ()) | ||
| done.acquire() | ||
|
|
||
| assert callback_idents | ||
| assert callback_idents[-1] == worker_idents[-1] | ||
| assert callback_idents[-1] != main_ident | ||
| print("gc hook ran on collecting worker") | ||
15 changes: 15 additions & 0 deletions
15
pyre/bench/synth/gc_native_strings_collectable.cranelift.jitstats
This file contains hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
15 changes: 15 additions & 0 deletions
15
pyre/bench/synth/gc_native_strings_collectable.dynasm.jitstats
This file contains hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
This file contains hidden or 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,60 @@ | ||
| # pyre-check: no-cpython | ||
| # pyre-check: skip-backends=wasm | ||
|
|
||
| import _io | ||
| import gc | ||
| import os | ||
| import time | ||
|
|
||
|
|
||
| results = [] | ||
|
|
||
|
|
||
| def managed(label, value): | ||
| results.append((label, value)) | ||
| return value | ||
|
|
||
|
|
||
| # Native filesystem objects have state-dependent repr branches. | ||
| entry = next(os.scandir(".")) | ||
| managed("DirEntry repr", os.DirEntry.__repr__(entry)) | ||
|
|
||
| file = _io.FileIO(__file__, "r") | ||
| managed("FileIO name repr", _io.FileIO.__repr__(file)) | ||
| del file.name | ||
| managed("FileIO fd repr", _io.FileIO.__repr__(file)) | ||
| file.close() | ||
| managed("FileIO closed repr", _io.FileIO.__repr__(file)) | ||
|
|
||
|
|
||
| # Unix and Windows have separate libc-backed strftime implementations, while | ||
| # asctime and ctime share the upstream-style formatter. | ||
| calendar = (2020, 2, 3, 4, 5, 6, 0, 34, -1) | ||
| strftime_value = time.strftime("%Y-%m-%d %H:%M:%S", calendar) | ||
| assert strftime_value == "2020-02-03 04:05:06" | ||
| managed("strftime", strftime_value) | ||
|
|
||
| asctime_value = time.asctime(calendar) | ||
| assert asctime_value == "Mon Feb 3 04:05:06 2020" | ||
| managed("asctime", asctime_value) | ||
| managed("ctime", time.ctime(0)) | ||
|
|
||
|
|
||
| # pyre's mmap implementation is currently Unix-only. The module imports on | ||
| # Windows without exposing mmap.mmap, so keep the platform branch in this one | ||
| # native fixture instead of maintaining another process/baseline pair. | ||
| import mmap | ||
|
|
||
|
|
||
| if hasattr(mmap, "mmap"): | ||
| mapping = mmap.mmap(-1, 1) | ||
| managed("mmap live repr", mmap.mmap.__repr__(mapping)) | ||
| mapping.close() | ||
| managed("mmap closed repr", mmap.mmap.__repr__(mapping)) | ||
|
|
||
|
|
||
| objects = gc.get_objects() | ||
| for label, value in results: | ||
| assert any(obj is value for obj in objects), label | ||
|
|
||
| print("native runtime string results are collectable") |
15 changes: 15 additions & 0 deletions
15
pyre/bench/synth/gc_runtime_strings_collectable.cranelift.jitstats
This file contains hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
15 changes: 15 additions & 0 deletions
15
pyre/bench/synth/gc_runtime_strings_collectable.dynasm.jitstats
This file contains hidden or 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,15 @@ | ||
| bridges_compiled=0 | ||
| descr_set_absent=0 | ||
| descr_set_ambiguous=0 | ||
| descr_set_stale_absent=0 | ||
| fbw_blackhole_adopted_multi_frame=0 | ||
| fbw_blackhole_adopted_single_frame=0 | ||
| fbw_rolled_back_with_effects=0 | ||
| fbw_store_journal_rollback_failed=0 | ||
| field_pos_attached_misplaced=0 | ||
| field_pos_spec_misplaced=0 | ||
| guard_failures=0 | ||
| internal_compile_panics=0 | ||
| loops_aborted=0 | ||
| loops_compiled=0 | ||
| retraces_compiled=0 |
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Rename the unused callback parameter.
Ruff reports
statsas unused. Rename it to_statsand preserve the callback signature.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.16.1)
[warning] 16-16: Unused function argument:
stats(ARG001)
🤖 Prompt for AI Agents
Source: Linters/SAST tools