Skip to content
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

Include subsegment information when aggregating split statistics #433

Merged

Conversation

forestbelton
Copy link
Contributor

@forestbelton forestbelton commented Dec 8, 2024

Fixes #432

Description

Extend util.Statistics so that it breaks out statistics for segments which include subsegments.

I extended the base Segment type to include a property statistics for querying subsegment statistics, defaulting to the current segment information only. CommonSegGroup overrides this to provide aggregated statistics based on all of its subsegments.

Caveat

This change has the effect that a segment inheriting from CommonSegGroup will not be itself included in the statistics output. An example is given in the test output below.

I'm not sure if this is desired behavior, but I couldn't figure out a way to incorporate both subsegment information and retain the segment name without changing the output into some kind of tree format.

Test output

Using the following segment configuration:

segments:
  - [0x0, header]
  - type: code
    start: 0x800
    vram: 0x8002D000
    subsegments:
      - [0x800, bin]
      - [0x101f8, asm, a]
      - [0x102a8, bin]
      - [0x349a8, asm, b]
      - [0x349c8, bin]
      - [0x34b50, asm, c]
      - [0x34bd0, bin]
  - [0x80000]

Before:

Split 524 KB (100.00%) in defined segments
              header:     2 KB (0.39%) 1 split, 0 cached
                code:   522 KB (99.61%) 1 split, 0 cached
             unknown:      0 B (0.00%) from unknown bin files

After:

Split 2 KB (0.45%) in defined segments
              header:     2 KB (0.39%) 1 split, 0 cached
                 asm:    336 B (0.06%) 3 split, 0 cached
             unknown:   521 KB (99.55%) from unknown bin files

Comment on lines +40 to +41
if self.is_name_default():
stats_type = "unk"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code was checking for bin types too.
I'm not sure if we should keep that check tho, naming the section itself could be considered as it being known, idk.
What do you think @ethteck ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think considering it known if it's named is totally fine, personally

Copy link
Owner

@ethteck ethteck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Just one q

@@ -1,4 +1,4 @@
from ...segtypes.segment import Segment
from ...segtypes.segment import Segment, SegmentType
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a type alias to make the types for the code I introduced more self-documenting — certainly not necessary

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I hadn't understood the full context of it. thank you!

Comment on lines +40 to +41
if self.is_name_default():
stats_type = "unk"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think considering it known if it's named is totally fine, personally

@ethteck
Copy link
Owner

ethteck commented Dec 10, 2024

@forestbelton before I merge, could you add an entry to the changelog for this? Under 0.32.1

@ethteck ethteck merged commit d3c3d97 into ethteck:main Dec 12, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading split statistics for code subsegments
3 participants