Skip to content

Refactor from_frame_stack into a rule-table architecture (no behavior change)#16

Closed
Chenguang-Zhu wants to merge 1 commit into
facebookresearch:mainfrom
Chenguang-Zhu:export-D103992611
Closed

Refactor from_frame_stack into a rule-table architecture (no behavior change)#16
Chenguang-Zhu wants to merge 1 commit into
facebookresearch:mainfrom
Chenguang-Zhu:export-D103992611

Conversation

@Chenguang-Zhu

Copy link
Copy Markdown
Member

Summary:
Pure refactor of AllocationType.from_frame_stack. Replace the flat
for-loop if-cascade with a list of (predicate, category) rules at
module scope and add small private helper predicates:

  • _any_filename_contains
  • _any_filename_matches_regex
  • _any_frame_name_in
  • _any_frame_name_contains
  • _any_frame_name_startswith
  • _no_frame_name_in

The 12 existing rules are migrated 1-to-1 in their original priority
order. The function body becomes "iterate the table; first matching
rule wins; else UNKNOWN". This sets up subsequent diffs to add new
rules without bloating the function body.

Differential Revision: D103992611

… change)

Summary:
Pure refactor of `AllocationType.from_frame_stack`. Replace the flat
for-loop if-cascade with a list of `(predicate, category)` rules at
module scope and add small private helper predicates:

- `_any_filename_contains`
- `_any_filename_matches_regex`
- `_any_frame_name_in`
- `_any_frame_name_contains`
- `_any_frame_name_startswith`
- `_no_frame_name_in`

The 12 existing rules are migrated 1-to-1 in their original priority
order. The function body becomes "iterate the table; first matching
rule wins; else UNKNOWN". This sets up subsequent diffs to add new
rules without bloating the function body.

Differential Revision: D103992611
@meta-cla meta-cla Bot added the cla signed label May 7, 2026
@meta-codesync

meta-codesync Bot commented May 7, 2026

Copy link
Copy Markdown

@Chenguang-Zhu has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103992611.

@meta-codesync

meta-codesync Bot commented May 7, 2026

Copy link
Copy Markdown

This pull request has been merged in b5095dd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant