Skip to content

Commit

Permalink
pw_allocator: Refactor size reports
Browse files Browse the repository at this point in the history
This CL is the first step in a series that decomposes the size reports
into portions for blocks, buckets, and allocators in order to make it
clearer what components contribute what portion of the overall code
size.

Change-Id: I7fc521f36cf46dc9018e4e5da8aa14bb3e9feb1a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/264636
Reviewed-by: Wyatt Hepler <[email protected]>
Lint: Lint 🤖 <[email protected]>
Commit-Queue: Aaron Green <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
nopsledder authored and CQ Bot Account committed Feb 13, 2025
1 parent fb3288a commit 5f8f25b
Show file tree
Hide file tree
Showing 32 changed files with 919 additions and 581 deletions.
2 changes: 1 addition & 1 deletion docs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ _doxygen_input_files = [ # keep-sorted: start
"$dir_pw_allocator/public/pw_allocator/null_allocator.h",
"$dir_pw_allocator/public/pw_allocator/pmr_allocator.h",
"$dir_pw_allocator/public/pw_allocator/pool.h",
"$dir_pw_allocator/public/pw_allocator/size_reporter.h",
"$dir_pw_allocator/public/pw_allocator/synchronized_allocator.h",
"$dir_pw_allocator/public/pw_allocator/test_harness.h",
"$dir_pw_allocator/public/pw_allocator/testing.h",
Expand All @@ -209,6 +208,7 @@ _doxygen_input_files = [ # keep-sorted: start
"$dir_pw_allocator/public/pw_allocator/typed_pool.h",
"$dir_pw_allocator/public/pw_allocator/unique_ptr.h",
"$dir_pw_allocator/public/pw_allocator/worst_fit.h",
"$dir_pw_allocator/size_report/public/pw_allocator/size_report/size_report.h",
"$dir_pw_analog/public/pw_analog/analog_input.h",
"$dir_pw_analog/public/pw_analog/microvolt_input.h",
"$dir_pw_async/public/pw_async/context.h",
Expand Down
232 changes: 220 additions & 12 deletions pw_allocator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_bloat:pw_size_diff.bzl", "pw_size_diff")
load("//pw_bloat:pw_size_table.bzl", "pw_size_table")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

Expand Down Expand Up @@ -769,17 +771,6 @@ pw_cc_test(
],
)

cc_library(
name = "size_reporter",
hdrs = ["public/pw_allocator/size_reporter.h"],
strip_include_prefix = "public",
deps = [
":null_allocator",
"//pw_bloat:bloat_this_binary",
"//pw_bytes",
],
)

# Docs

filegroup(
Expand Down Expand Up @@ -807,7 +798,6 @@ filegroup(
"public/pw_allocator/null_allocator.h",
"public/pw_allocator/pmr_allocator.h",
"public/pw_allocator/pool.h",
"public/pw_allocator/size_reporter.h",
"public/pw_allocator/synchronized_allocator.h",
"public/pw_allocator/test_harness.h",
"public/pw_allocator/testing.h",
Expand All @@ -818,7 +808,224 @@ filegroup(
"public/pw_allocator/worst_fit.h",
"//pw_allocator/block:doxygen",
"//pw_allocator/bucket:doxygen",
"//pw_allocator/size_report:doxygen",
],
)

pw_size_diff(
name = "null_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "NullAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:null_allocator",
)

pw_size_table(
name = "allocator_api_size_report",
reports = [
":null_allocator_size_report",
],
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
)

pw_size_diff(
name = "best_fit_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "BestFitAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:best_fit",
)

pw_size_diff(
name = "bucket_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "BucketAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:bucket_allocator",
)

pw_size_diff(
name = "first_fit_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "FirstFitAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:first_fit",
)

pw_size_diff(
name = "tlsf_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "TlsfAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:tlsf_allocator",
)

pw_size_diff(
name = "worst_fit_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "WorstFitAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:worst_fit",
)

pw_size_table(
name = "block_allocators_size_report",
reports = [
":best_fit_size_report",
":bucket_allocator_size_report",
":first_fit_size_report",
":tlsf_allocator_size_report",
":worst_fit_size_report",
],
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
)

pw_size_diff(
name = "buddy_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "BuddyAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:buddy_allocator",
)

pw_size_diff(
name = "bump_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "BumpAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:bump_allocator",
)

pw_size_diff(
name = "libc_allocator_size_report",
base = "//pw_allocator/size_report:base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "LibCAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:libc_allocator",
)

pw_size_table(
name = "concrete_allocators_size_report",
reports = [
":buddy_allocator_size_report",
":bump_allocator_size_report",
":libc_allocator_size_report",
],
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
)

pw_size_diff(
name = "fallback_allocator_size_report",
base = "//pw_allocator/size_report:best_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "FallbackAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:fallback_allocator",
)

pw_size_diff(
name = "pmr_allocator_size_report",
base = "//pw_allocator/size_report:pmr_allocator_base",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "AsPmrAllocator",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:pmr_allocator",
)

pw_size_diff(
name = "synchronized_allocator_size_report_isl",
base = "//pw_allocator/size_report:best_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "SynchronizedAllocator<sync::InterruptSpinLock>",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:synchronized_allocator_isl",
)

pw_size_diff(
name = "synchronized_allocator_size_report_mutex",
base = "//pw_allocator/size_report:best_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "SynchronizedAllocator<sync::Mutex>",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:synchronized_allocator_mutex",
)

pw_size_diff(
name = "tracking_allocator_size_report_all_metrics",
base = "//pw_allocator/size_report:best_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "TrackingAllocator<AllMetrics>",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:tracking_allocator_all_metrics",
)

pw_size_diff(
name = "tracking_allocator_size_report_no_metrics",
base = "//pw_allocator/size_report:best_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "TrackingAllocator<NoMetrics>",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:tracking_allocator_no_metrics",
)

pw_size_table(
name = "forwarding_allocators_size_report",
reports = [
":fallback_allocator_size_report",
":pmr_allocator_size_report",
":synchronized_allocator_size_report_isl",
":synchronized_allocator_size_report_mutex",
":tracking_allocator_size_report_all_metrics",
":tracking_allocator_size_report_no_metrics",
],
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
)

pw_size_diff(
name = "unique_ptr_size_report",
base = "//pw_allocator/size_report:first_fit",
bloaty_config = "//targets/rp2040:bloaty_config",
label = "UniquePtr",
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
target = "//pw_allocator/size_report:unique_ptr",
)

pw_size_table(
name = "allocator_utilities_size_report",
reports = [
":unique_ptr_size_report",
],
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
tags = ["manual"],
)

sphinx_docs_library(
Expand All @@ -830,6 +1037,7 @@ sphinx_docs_library(
"docs.rst",
"guide.rst",
"//pw_allocator/examples:docs",
"//pw_allocator/size_report:docs",
],
prefix = "pw_allocator/",
target_compatible_with = incompatible_with_mcu(),
Expand Down
Loading

0 comments on commit 5f8f25b

Please sign in to comment.