Skip to content

Commit 5f8f25b

Browse files
nopsledderCQ Bot Account
authored andcommitted
pw_allocator: Refactor size reports
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]>
1 parent fb3288a commit 5f8f25b

32 files changed

+919
-581
lines changed

docs/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ _doxygen_input_files = [ # keep-sorted: start
200200
"$dir_pw_allocator/public/pw_allocator/null_allocator.h",
201201
"$dir_pw_allocator/public/pw_allocator/pmr_allocator.h",
202202
"$dir_pw_allocator/public/pw_allocator/pool.h",
203-
"$dir_pw_allocator/public/pw_allocator/size_reporter.h",
204203
"$dir_pw_allocator/public/pw_allocator/synchronized_allocator.h",
205204
"$dir_pw_allocator/public/pw_allocator/test_harness.h",
206205
"$dir_pw_allocator/public/pw_allocator/testing.h",
@@ -209,6 +208,7 @@ _doxygen_input_files = [ # keep-sorted: start
209208
"$dir_pw_allocator/public/pw_allocator/typed_pool.h",
210209
"$dir_pw_allocator/public/pw_allocator/unique_ptr.h",
211210
"$dir_pw_allocator/public/pw_allocator/worst_fit.h",
211+
"$dir_pw_allocator/size_report/public/pw_allocator/size_report/size_report.h",
212212
"$dir_pw_analog/public/pw_analog/analog_input.h",
213213
"$dir_pw_analog/public/pw_analog/microvolt_input.h",
214214
"$dir_pw_async/public/pw_async/context.h",

pw_allocator/BUILD.bazel

Lines changed: 220 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1616
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17+
load("//pw_bloat:pw_size_diff.bzl", "pw_size_diff")
18+
load("//pw_bloat:pw_size_table.bzl", "pw_size_table")
1719
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
1820
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
1921

@@ -769,17 +771,6 @@ pw_cc_test(
769771
],
770772
)
771773

772-
cc_library(
773-
name = "size_reporter",
774-
hdrs = ["public/pw_allocator/size_reporter.h"],
775-
strip_include_prefix = "public",
776-
deps = [
777-
":null_allocator",
778-
"//pw_bloat:bloat_this_binary",
779-
"//pw_bytes",
780-
],
781-
)
782-
783774
# Docs
784775

785776
filegroup(
@@ -807,7 +798,6 @@ filegroup(
807798
"public/pw_allocator/null_allocator.h",
808799
"public/pw_allocator/pmr_allocator.h",
809800
"public/pw_allocator/pool.h",
810-
"public/pw_allocator/size_reporter.h",
811801
"public/pw_allocator/synchronized_allocator.h",
812802
"public/pw_allocator/test_harness.h",
813803
"public/pw_allocator/testing.h",
@@ -818,7 +808,224 @@ filegroup(
818808
"public/pw_allocator/worst_fit.h",
819809
"//pw_allocator/block:doxygen",
820810
"//pw_allocator/bucket:doxygen",
811+
"//pw_allocator/size_report:doxygen",
812+
],
813+
)
814+
815+
pw_size_diff(
816+
name = "null_allocator_size_report",
817+
base = "//pw_allocator/size_report:base",
818+
bloaty_config = "//targets/rp2040:bloaty_config",
819+
label = "NullAllocator",
820+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
821+
tags = ["manual"],
822+
target = "//pw_allocator/size_report:null_allocator",
823+
)
824+
825+
pw_size_table(
826+
name = "allocator_api_size_report",
827+
reports = [
828+
":null_allocator_size_report",
829+
],
830+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
831+
tags = ["manual"],
832+
)
833+
834+
pw_size_diff(
835+
name = "best_fit_size_report",
836+
base = "//pw_allocator/size_report:base",
837+
bloaty_config = "//targets/rp2040:bloaty_config",
838+
label = "BestFitAllocator",
839+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
840+
tags = ["manual"],
841+
target = "//pw_allocator/size_report:best_fit",
842+
)
843+
844+
pw_size_diff(
845+
name = "bucket_allocator_size_report",
846+
base = "//pw_allocator/size_report:base",
847+
bloaty_config = "//targets/rp2040:bloaty_config",
848+
label = "BucketAllocator",
849+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
850+
tags = ["manual"],
851+
target = "//pw_allocator/size_report:bucket_allocator",
852+
)
853+
854+
pw_size_diff(
855+
name = "first_fit_size_report",
856+
base = "//pw_allocator/size_report:base",
857+
bloaty_config = "//targets/rp2040:bloaty_config",
858+
label = "FirstFitAllocator",
859+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
860+
tags = ["manual"],
861+
target = "//pw_allocator/size_report:first_fit",
862+
)
863+
864+
pw_size_diff(
865+
name = "tlsf_allocator_size_report",
866+
base = "//pw_allocator/size_report:base",
867+
bloaty_config = "//targets/rp2040:bloaty_config",
868+
label = "TlsfAllocator",
869+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
870+
tags = ["manual"],
871+
target = "//pw_allocator/size_report:tlsf_allocator",
872+
)
873+
874+
pw_size_diff(
875+
name = "worst_fit_size_report",
876+
base = "//pw_allocator/size_report:base",
877+
bloaty_config = "//targets/rp2040:bloaty_config",
878+
label = "WorstFitAllocator",
879+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
880+
tags = ["manual"],
881+
target = "//pw_allocator/size_report:worst_fit",
882+
)
883+
884+
pw_size_table(
885+
name = "block_allocators_size_report",
886+
reports = [
887+
":best_fit_size_report",
888+
":bucket_allocator_size_report",
889+
":first_fit_size_report",
890+
":tlsf_allocator_size_report",
891+
":worst_fit_size_report",
892+
],
893+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
894+
tags = ["manual"],
895+
)
896+
897+
pw_size_diff(
898+
name = "buddy_allocator_size_report",
899+
base = "//pw_allocator/size_report:base",
900+
bloaty_config = "//targets/rp2040:bloaty_config",
901+
label = "BuddyAllocator",
902+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
903+
tags = ["manual"],
904+
target = "//pw_allocator/size_report:buddy_allocator",
905+
)
906+
907+
pw_size_diff(
908+
name = "bump_allocator_size_report",
909+
base = "//pw_allocator/size_report:base",
910+
bloaty_config = "//targets/rp2040:bloaty_config",
911+
label = "BumpAllocator",
912+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
913+
tags = ["manual"],
914+
target = "//pw_allocator/size_report:bump_allocator",
915+
)
916+
917+
pw_size_diff(
918+
name = "libc_allocator_size_report",
919+
base = "//pw_allocator/size_report:base",
920+
bloaty_config = "//targets/rp2040:bloaty_config",
921+
label = "LibCAllocator",
922+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
923+
tags = ["manual"],
924+
target = "//pw_allocator/size_report:libc_allocator",
925+
)
926+
927+
pw_size_table(
928+
name = "concrete_allocators_size_report",
929+
reports = [
930+
":buddy_allocator_size_report",
931+
":bump_allocator_size_report",
932+
":libc_allocator_size_report",
933+
],
934+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
935+
tags = ["manual"],
936+
)
937+
938+
pw_size_diff(
939+
name = "fallback_allocator_size_report",
940+
base = "//pw_allocator/size_report:best_fit",
941+
bloaty_config = "//targets/rp2040:bloaty_config",
942+
label = "FallbackAllocator",
943+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
944+
tags = ["manual"],
945+
target = "//pw_allocator/size_report:fallback_allocator",
946+
)
947+
948+
pw_size_diff(
949+
name = "pmr_allocator_size_report",
950+
base = "//pw_allocator/size_report:pmr_allocator_base",
951+
bloaty_config = "//targets/rp2040:bloaty_config",
952+
label = "AsPmrAllocator",
953+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
954+
tags = ["manual"],
955+
target = "//pw_allocator/size_report:pmr_allocator",
956+
)
957+
958+
pw_size_diff(
959+
name = "synchronized_allocator_size_report_isl",
960+
base = "//pw_allocator/size_report:best_fit",
961+
bloaty_config = "//targets/rp2040:bloaty_config",
962+
label = "SynchronizedAllocator<sync::InterruptSpinLock>",
963+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
964+
tags = ["manual"],
965+
target = "//pw_allocator/size_report:synchronized_allocator_isl",
966+
)
967+
968+
pw_size_diff(
969+
name = "synchronized_allocator_size_report_mutex",
970+
base = "//pw_allocator/size_report:best_fit",
971+
bloaty_config = "//targets/rp2040:bloaty_config",
972+
label = "SynchronizedAllocator<sync::Mutex>",
973+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
974+
tags = ["manual"],
975+
target = "//pw_allocator/size_report:synchronized_allocator_mutex",
976+
)
977+
978+
pw_size_diff(
979+
name = "tracking_allocator_size_report_all_metrics",
980+
base = "//pw_allocator/size_report:best_fit",
981+
bloaty_config = "//targets/rp2040:bloaty_config",
982+
label = "TrackingAllocator<AllMetrics>",
983+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
984+
tags = ["manual"],
985+
target = "//pw_allocator/size_report:tracking_allocator_all_metrics",
986+
)
987+
988+
pw_size_diff(
989+
name = "tracking_allocator_size_report_no_metrics",
990+
base = "//pw_allocator/size_report:best_fit",
991+
bloaty_config = "//targets/rp2040:bloaty_config",
992+
label = "TrackingAllocator<NoMetrics>",
993+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
994+
tags = ["manual"],
995+
target = "//pw_allocator/size_report:tracking_allocator_no_metrics",
996+
)
997+
998+
pw_size_table(
999+
name = "forwarding_allocators_size_report",
1000+
reports = [
1001+
":fallback_allocator_size_report",
1002+
":pmr_allocator_size_report",
1003+
":synchronized_allocator_size_report_isl",
1004+
":synchronized_allocator_size_report_mutex",
1005+
":tracking_allocator_size_report_all_metrics",
1006+
":tracking_allocator_size_report_no_metrics",
1007+
],
1008+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
1009+
tags = ["manual"],
1010+
)
1011+
1012+
pw_size_diff(
1013+
name = "unique_ptr_size_report",
1014+
base = "//pw_allocator/size_report:first_fit",
1015+
bloaty_config = "//targets/rp2040:bloaty_config",
1016+
label = "UniquePtr",
1017+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
1018+
tags = ["manual"],
1019+
target = "//pw_allocator/size_report:unique_ptr",
1020+
)
1021+
1022+
pw_size_table(
1023+
name = "allocator_utilities_size_report",
1024+
reports = [
1025+
":unique_ptr_size_report",
8211026
],
1027+
# TODO: https://pwbug.dev/388905812 - Make size reports always build.
1028+
tags = ["manual"],
8221029
)
8231030

8241031
sphinx_docs_library(
@@ -830,6 +1037,7 @@ sphinx_docs_library(
8301037
"docs.rst",
8311038
"guide.rst",
8321039
"//pw_allocator/examples:docs",
1040+
"//pw_allocator/size_report:docs",
8331041
],
8341042
prefix = "pw_allocator/",
8351043
target_compatible_with = incompatible_with_mcu(),

0 commit comments

Comments
 (0)