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

Make ConfigurationManager virtual #10195

Merged

Conversation

harimau-qirex
Copy link
Contributor

Problem

Making the configuration manager virtual will make it easier to change at runtime. Later changes can allow the ConfigurationMgr() accessor to be settable at runtime rather than a hardcoded static instance.

Change overview

Makes the ConfigurationManager interface pure virtual. GenericConfigurationManagerImpl now implements it directly, and calls on the Impl() for the ConfigurationManager methods have been removed. Other calls remain for interfaces not defined by the ConfigurationManager (e.g. the methods related to config values).

Testing

Ran the unit tests.

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2021

CLA assistant check
All committers have signed the CLA.

@yufengwangca
Copy link
Contributor

Currently, the Device Layer uses CRTP design pattern to make it easier to adapt the code to different platforms and operating contexts.

As part of its design, the CHIP Device Layer employs a pattern of static polymorphism to insulate its application-visible API from the underlying platform-specific implementation. A similar interface pattern is used within the Device Layer itself to provide compartmentalization between components.

Using static polymorphism instead of dynamic polymorphism (virtual function) is mainly based memory consideration. Since virtual function is extensively used within other core components, I think it make sense to look at if we need to switch PlatformLayer also to virtual functions. Lets see the memory consumption change with this PR.

@boring-cyborg boring-cyborg bot added the app label Oct 15, 2021
@harimau-qirex harimau-qirex force-pushed the virtual-configuration-manager branch from f04ac10 to b19f315 Compare October 15, 2021 18:20
@github-actions
Copy link

github-actions bot commented Oct 15, 2021

PR #10195: Size comparison from efc17de to b19f315

1 build
platform target config section efc17de b19f315 change % change
telink lighting-app tlsr9518adk80d bss 70984 70988 4 0.0
noinit 33216 33216 0 0.0
text 458146 458648 502 0.1

Increases above 1.0% from efc17de to b19f315:

platform target config section efc17de b19f315 change % change
linux all-clusters-app debug .data.rel.ro 58432 59744 1312 2.2
chip-tool debug .bss 17552 17744 192 1.1
.data.rel.ro 83312 84688 1376 1.7
.rodata 174560 184000 9440 5.4
.text 2421973 2457061 35088 1.4
ota-provider-app debug .data.rel.ro 23176 24488 1312 5.7
ota-requestor-app debug .data.rel.ro 24488 25800 1312 5.4
shell debug .data.rel.ro 35120 36496 1376 3.9
.rodata 71855 76431 4576 6.4
.text 568898 592994 24096 4.2
tv-app debug .data.rel.ro 55536 56848 1312 2.4
bridge-app debug+rpc .data.rel.ro 25496 26824 1328 5.2
.text 1050821 1061813 10992 1.0
lighting-app debug+rpc .data.rel.ro 52240 53552 1312 2.5
qpg persistent-storage-app qpg6100+debug .bss 17778 27840 10062 56.6
.data 280 372 92 32.9
.text 102704 149972 47268 46.0
19 builds
platform target config section efc17de b19f315 change % change
efr32 lighting-app BRD4161A .bss 118020 118020 0 0.0
.data 1800 1800 0 0.0
.text 782420 785116 2696 0.3
lock-app BRD4161A .bss 115892 115892 0 0.0
.data 1760 1760 0 0.0
.text 761724 764420 2696 0.4
window-app BRD4161A .bss 116212 116212 0 0.0
.data 1764 1764 0 0.0
.text 762632 765328 2696 0.4
lighting-app BRD4161A+rpc .bss 131348 131348 0 0.0
.data 1852 1852 0 0.0
.text 762148 764828 2680 0.4
k32w lock-app k32w061+debug .bss 69052 69052 0 0.0
.data 1864 1864 0 0.0
.text 515176 516692 1516 0.3
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357172 359428 2256 0.6
lighting-app k32w061+se05x+release .bss 78560 78568 8 0.0
.data 1900 1900 0 0.0
.text 613800 615300 1500 0.2
linux all-clusters-app debug .bss 52176 52208 32 0.1
.data 978 978 0 0.0
.data.rel.ro 58432 59744 1312 2.2
.dynamic 592 592 0 0.0
.got 4072 4080 8 0.2
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 135989 136277 288 0.2
.text 1326066 1334866 8800 0.7
chip-tool debug .bss 17552 17744 192 1.1
.data 1584 1584 0 0.0
.data.rel.ro 83312 84688 1376 1.7
.dynamic 592 592 0 0.0
.got 4328 4352 24 0.6
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 174560 184000 9440 5.4
.text 2421973 2457061 35088 1.4
ota-provider-app debug .bss 37472 37504 32 0.1
.data 752 752 0 0.0
.data.rel.ro 23176 24488 1312 5.7
.dynamic 592 592 0 0.0
.got 4008 4016 8 0.2
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 109848 110136 288 0.3
.text 1009314 1019234 9920 1.0
ota-requestor-app debug .bss 205728 205760 32 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 25800 1312 5.4
.dynamic 592 592 0 0.0
.got 4136 4144 8 0.2
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 127896 128184 288 0.2
.text 1128626 1138562 9936 0.9
shell debug .bss 16072 16136 64 0.4
.data 242 242 0 0.0
.data.rel.ro 35120 36496 1376 3.9
.dynamic 592 592 0 0.0
.got 3496 3528 32 0.9
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71855 76431 4576 6.4
.text 568898 592994 24096 4.2
tv-app debug .bss 216368 216400 32 0.0
.data 2032 2032 0 0.0
.data.rel.ro 55536 56848 1312 2.4
.dynamic 592 592 0 0.0
.got 4400 4408 8 0.2
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 151464 151720 256 0.2
.text 1462818 1471074 8256 0.6
bridge-app debug+rpc .bss 52880 52912 32 0.1
.data 976 976 0 0.0
.data.rel.ro 25496 26824 1328 5.2
.dynamic 592 592 0 0.0
.got 3944 3952 8 0.2
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110484 110772 288 0.3
.text 1050821 1061813 10992 1.0
lighting-app debug+rpc .bss 42200 42232 32 0.1
.data 1106 1106 0 0.0
.data.rel.ro 52240 53552 1312 2.5
.dynamic 608 608 0 0.0
.got 4104 4112 8 0.2
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127665 127921 256 0.2
.text 1252226 1260930 8704 0.7
p6 lock-app default .bss 68216 68224 8 0.0
.data 2416 2416 0 0.0
.heap 962712 962704 -8 -0.0
.text 1126280 1127688 1408 0.1
qpg lighting-app qpg6100+debug .bss 53536 53536 0 0.0
.data 996 1004 8 0.8
.text 486104 486568 464 0.1
lock-app qpg6100+debug .bss 52488 52488 0 0.0
.data 952 960 8 0.8
.text 462352 462824 472 0.1
persistent-storage-app qpg6100+debug .bss 17778 27840 10062 56.6
.data 280 372 92 32.9
.text 102704 149972 47268 46.0

Increases above 1.0% from efc17de to b19f315:

platform target config section efc17de b19f315 change % change
nrfconnect shell nrf52840dk_nrf52840 rodata 71640 72520 880 1.2
nrf5340dk_nrf5340_cpuapp rodata 66284 67164 880 1.3
14 builds
platform target config section efc17de b19f315 change % change
esp32 all-clusters-app c3devkit .dram0.bss 60280 60280 0 0.0
.dram0.data 16192 16200 8 0.0
.flash.rodata 198624 199416 792 0.4
.flash.text 870142 871398 1256 0.1
.iram0.text 57330 57330 0 0.0
m5stack .dram0.bss 62776 62784 8 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 207056 207824 768 0.4
.flash.text 900507 901687 1180 0.1
.iram0.text 125115 125115 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172148 172148 0 0.0
.data 5464 5464 0 0.0
.heap 858832 858832 0 0.0
.text 1219384 1220456 1072 0.1
lock-app CY8CPROTO_062_4343W+release .bss 171084 171084 0 0.0
.data 5432 5432 0 0.0
.heap 859928 859928 0 0.0
.text 1197440 1198512 1072 0.1
nrfconnect lighting-app nrf52840dk_nrf52840 bss 112316 112320 4 0.0
rodata 97528 97936 408 0.4
text 577428 577784 356 0.1
lock-app nrf52840dk_nrf52840 bss 111348 111352 4 0.0
rodata 94028 94436 408 0.4
text 558928 559284 356 0.1
pigweed-app nrf52840dk_nrf52840 bss 51772 51772 0 0.0
rodata 45772 45772 0 0.0
text 339392 339392 0 0.0
pump-app nrf52840dk_nrf52840 bss 111416 111420 4 0.0
rodata 95008 95416 408 0.4
text 562084 562436 352 0.1
pump-controller-app nrf52840dk_nrf52840 bss 111356 111360 4 0.0
rodata 94088 94496 408 0.4
text 558720 559076 356 0.1
shell nrf52840dk_nrf52840 bss 107316 107320 4 0.0
rodata 71640 72520 880 1.2
text 518908 520136 1228 0.2
lighting-app nrf52840dk_nrf52840+rpc bss 108556 108560 4 0.0
rodata 88320 88728 408 0.5
text 550632 550980 348 0.1
nrf5340dk_nrf5340_cpuapp bss 113688 113692 4 0.0
rodata 92772 93180 408 0.4
text 506888 507240 352 0.1
lock-app nrf5340dk_nrf5340_cpuapp bss 112720 112724 4 0.0
rodata 89284 89692 408 0.5
text 488380 488736 356 0.1
shell nrf5340dk_nrf5340_cpuapp bss 108300 108304 4 0.0
rodata 66284 67164 880 1.3
text 439504 440728 1224 0.3

@github-actions
Copy link

github-actions bot commented Oct 15, 2021

PR #10195: Size comparison from efc17de to ebd0ae4

Increases above 1.0% from efc17de to ebd0ae4:

platform target config section efc17de ebd0ae4 change % change
qpg persistent-storage-app qpg6100+debug .bss 17778 27840 10062 56.6
.data 280 372 92 32.9
.text 102704 149972 47268 46.0
8 builds
platform target config section efc17de ebd0ae4 change % change
k32w lock-app k32w061+debug .bss 69052 69052 0 0.0
.data 1864 1864 0 0.0
.text 515176 516692 1516 0.3
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357172 359428 2256 0.6
lighting-app k32w061+se05x+release .bss 78560 78568 8 0.0
.data 1900 1900 0 0.0
.text 613800 615300 1500 0.2
p6 lock-app default .bss 68216 68224 8 0.0
.data 2416 2416 0 0.0
.heap 962712 962704 -8 -0.0
.text 1126280 1127688 1408 0.1
qpg lighting-app qpg6100+debug .bss 53536 53536 0 0.0
.data 996 1004 8 0.8
.text 486104 486568 464 0.1
lock-app qpg6100+debug .bss 52488 52488 0 0.0
.data 952 960 8 0.8
.text 462352 462824 472 0.1
persistent-storage-app qpg6100+debug .bss 17778 27840 10062 56.6
.data 280 372 92 32.9
.text 102704 149972 47268 46.0
telink lighting-app tlsr9518adk80d bss 70984 70988 4 0.0
noinit 33216 33216 0 0.0
text 458146 458648 502 0.1

Increases above 1.0% from efc17de to ebd0ae4:

platform target config section efc17de ebd0ae4 change % change
linux all-clusters-app debug .data.rel.ro 58432 59744 1312 2.2
chip-tool debug .bss 17552 17744 192 1.1
.data.rel.ro 83312 84688 1376 1.7
.rodata 174560 184000 9440 5.4
.text 2421973 2457061 35088 1.4
ota-provider-app debug .data.rel.ro 23176 24488 1312 5.7
ota-requestor-app debug .data.rel.ro 24488 25800 1312 5.4
shell debug .data.rel.ro 35120 36496 1376 3.9
.rodata 71855 76431 4576 6.4
.text 568898 592994 24096 4.2
tv-app debug .data.rel.ro 55536 56848 1312 2.4
bridge-app debug+rpc .data.rel.ro 25496 26824 1328 5.2
.text 1050821 1061813 10992 1.0
lighting-app debug+rpc .data.rel.ro 52240 53552 1312 2.5
14 builds
platform target config section efc17de ebd0ae4 change % change
efr32 lighting-app BRD4161A .bss 118020 118020 0 0.0
.data 1800 1800 0 0.0
.text 782420 785116 2696 0.3
lock-app BRD4161A .bss 115892 115892 0 0.0
.data 1760 1760 0 0.0
.text 761724 764420 2696 0.4
window-app BRD4161A .bss 116212 116212 0 0.0
.data 1764 1764 0 0.0
.text 762632 765328 2696 0.4
lighting-app BRD4161A+rpc .bss 131348 131348 0 0.0
.data 1852 1852 0 0.0
.text 762148 764828 2680 0.4
linux all-clusters-app debug .bss 52176 52208 32 0.1
.data 978 978 0 0.0
.data.rel.ro 58432 59744 1312 2.2
.dynamic 592 592 0 0.0
.got 4072 4080 8 0.2
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 135989 136277 288 0.2
.text 1326066 1334866 8800 0.7
chip-tool debug .bss 17552 17744 192 1.1
.data 1584 1584 0 0.0
.data.rel.ro 83312 84688 1376 1.7
.dynamic 592 592 0 0.0
.got 4328 4352 24 0.6
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 174560 184000 9440 5.4
.text 2421973 2457061 35088 1.4
ota-provider-app debug .bss 37472 37504 32 0.1
.data 752 752 0 0.0
.data.rel.ro 23176 24488 1312 5.7
.dynamic 592 592 0 0.0
.got 4008 4016 8 0.2
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 109848 110136 288 0.3
.text 1009314 1019234 9920 1.0
ota-requestor-app debug .bss 205728 205760 32 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 25800 1312 5.4
.dynamic 592 592 0 0.0
.got 4136 4144 8 0.2
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 127896 128184 288 0.2
.text 1128626 1138562 9936 0.9
shell debug .bss 16072 16136 64 0.4
.data 242 242 0 0.0
.data.rel.ro 35120 36496 1376 3.9
.dynamic 592 592 0 0.0
.got 3496 3528 32 0.9
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71855 76431 4576 6.4
.text 568898 592994 24096 4.2
tv-app debug .bss 216368 216400 32 0.0
.data 2032 2032 0 0.0
.data.rel.ro 55536 56848 1312 2.4
.dynamic 592 592 0 0.0
.got 4400 4408 8 0.2
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 151464 151720 256 0.2
.text 1462818 1471074 8256 0.6
bridge-app debug+rpc .bss 52880 52912 32 0.1
.data 976 976 0 0.0
.data.rel.ro 25496 26824 1328 5.2
.dynamic 592 592 0 0.0
.got 3944 3952 8 0.2
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110484 110772 288 0.3
.text 1050821 1061813 10992 1.0
lighting-app debug+rpc .bss 42200 42232 32 0.1
.data 1106 1106 0 0.0
.data.rel.ro 52240 53552 1312 2.5
.dynamic 608 608 0 0.0
.got 4104 4112 8 0.2
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127665 127921 256 0.2
.text 1252226 1260930 8704 0.7
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172148 172148 0 0.0
.data 5464 5464 0 0.0
.heap 858832 858832 0 0.0
.text 1219384 1220456 1072 0.1
lock-app CY8CPROTO_062_4343W+release .bss 171084 171084 0 0.0
.data 5432 5432 0 0.0
.heap 859928 859928 0 0.0
.text 1197440 1198512 1072 0.1
2 builds
platform target config section efc17de ebd0ae4 change % change
esp32 all-clusters-app c3devkit .dram0.bss 60280 60280 0 0.0
.dram0.data 16192 16200 8 0.0
.flash.rodata 198624 199416 792 0.4
.flash.text 870142 871398 1256 0.1
.iram0.text 57330 57330 0 0.0
m5stack .dram0.bss 62776 62784 8 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 207056 207824 768 0.4
.flash.text 900507 901779 1272 0.1
.iram0.text 125115 125115 0 0.0

Increases above 1.0% from efc17de to ebd0ae4:

platform target config section efc17de ebd0ae4 change % change
nrfconnect shell nrf52840dk_nrf52840 rodata 71640 72520 880 1.2
nrf5340dk_nrf5340_cpuapp rodata 66284 67164 880 1.3
10 builds
platform target config section efc17de ebd0ae4 change % change
nrfconnect lighting-app nrf52840dk_nrf52840 bss 112316 112320 4 0.0
rodata 97528 97936 408 0.4
text 577428 577784 356 0.1
lock-app nrf52840dk_nrf52840 bss 111348 111352 4 0.0
rodata 94028 94436 408 0.4
text 558928 559284 356 0.1
pigweed-app nrf52840dk_nrf52840 bss 51772 51772 0 0.0
rodata 45772 45772 0 0.0
text 339392 339392 0 0.0
pump-app nrf52840dk_nrf52840 bss 111416 111420 4 0.0
rodata 95008 95416 408 0.4
text 562084 562436 352 0.1
pump-controller-app nrf52840dk_nrf52840 bss 111356 111360 4 0.0
rodata 94088 94496 408 0.4
text 558720 559076 356 0.1
shell nrf52840dk_nrf52840 bss 107316 107320 4 0.0
rodata 71640 72520 880 1.2
text 518908 520136 1228 0.2
lighting-app nrf52840dk_nrf52840+rpc bss 108556 108560 4 0.0
rodata 88320 88728 408 0.5
text 550632 550980 348 0.1
nrf5340dk_nrf5340_cpuapp bss 113688 113692 4 0.0
rodata 92772 93180 408 0.4
text 506888 507240 352 0.1
lock-app nrf5340dk_nrf5340_cpuapp bss 112720 112724 4 0.0
rodata 89284 89692 408 0.5
text 488380 488736 356 0.1
shell nrf5340dk_nrf5340_cpuapp bss 108300 108304 4 0.0
rodata 66284 67164 880 1.3
text 439504 440728 1224 0.3

@harimau-qirex
Copy link
Contributor Author

harimau-qirex commented Oct 18, 2021

I've run the diffsyms.py script and investigated what's causing the size increase (with the Linux chip-tool as a first check). The difference is largely due to the fact that many ConfigurationManager (and Impl) symbols are optimized out of the master build because they don't get used, and that leads to other non-ConfigurationManager symbols that also get removed because now nothing uses them. When the ConfigurationManager is virtual, these calls can't get optimized out and so the full cost is paid for them.

The top three symbols that were included with this change that aren't included on master are:
wpa_fi_w1_wpa_supplicant1_interface_default_init
void chip::DeviceLayer::Internal::RunConfigUnitTest<chip::DeviceLayer::Internal::PosixConfig>()
openthread_io_openthread_border_router_default_init

These alone account for a bit less than 18 kB. There are about twenty related to config-value storage (PosixConfig, ChipLinuxStorage, ChipLinuxStorageIni) that are about another 8 kB. The unused ConfigurationManager methods add up to about another 8 kB. The remaining few kB generally seem to be directly related to the virtualization (1248 B for vtables, plus increases to ConfigurationMgr() call sites).

@andy31415
Copy link
Contributor

Now that #10528 has been merged would it make sense to update this PR and check sizes again?

@yufengwangca
Copy link
Contributor

I've run the diffsyms.py script and investigated what's causing the size increase (with the Linux chip-tool as a first check). The difference is largely due to the fact that many ConfigurationManager (and Impl) symbols are optimized out of the master build because they don't get used, and that leads to other non-ConfigurationManager symbols that also get removed because now nothing uses them. When the ConfigurationManager is virtual, these calls can't get optimized out and so the full cost is paid for them.

The top three symbols that were included with this change that aren't included on master are: wpa_fi_w1_wpa_supplicant1_interface_default_init void chip::DeviceLayer::Internal::RunConfigUnitTestchip::DeviceLayer::Internal::PosixConfig() openthread_io_openthread_border_router_default_init

These alone account for a bit less than 18 kB. There are about twenty related to config-value storage (PosixConfig, ChipLinuxStorage, ChipLinuxStorageIni) that are about another 8 kB. The unused ConfigurationManager methods add up to about another 8 kB. The remaining few kB generally seem to be directly related to the virtualization (1248 B for vtables, plus increases to ConfigurationMgr() call sites).

Hi Andy,

I was wondering if we can optimize the flash further. If we decide to proceed with virtual function route, then we need to convert all platform classes from CRTP to virtual functions, the add-up cost of flash increase could be huge.

After we switching to virtual interface, I think we should be able to clean up some files from current hierarchy, such as GenericConfigurationMgrImpl.h/GenericConfigurationMgrImpl.cpp since ConfigurationMgr can define the default implementation by itself.

We just need to have each platforms define their own ConfigurationMgrImpl class which inherits from ConfigurationMgr class and override the functions they need.

@harimau-qirex
Copy link
Contributor Author

Yufeng:
Currently each platform (other than fake/) already implements their own ConfigurationManagerImpl that overrides a small number of functions from GenericConfigurationManagerImpl, as well as provide a number of functions that GenericConfigurationManagerImpl requires. It should be possible to fold GenericConfigurationManagerImpl into the base class. It may not be necessary depending on future changes, as I think there are a number of methods that won't be used by the SDK and can be made implementation-only, rather than part of the ConfigurationManager interface.

Andrei:
This has already been updated with those changes. I don't think that the methods removed in that change contributed much to the size difference because they didn't reference external code. A significant part of the increase on Linux is due to bringing back indirectly referenced methods that had been optimized out.

For methods that were optimized out:

  • The method will eventually be used by the SDK and/or app, or
  • That example doesn't need that part of the spec, or
  • The method shouldn't exist as part of the ConfigurationManager interface.

The first case is unavoidable and the cost will need to be paid, either by this pull request or by someone else's in the future when it gets used.

The second case is addressed by the part of the plan to create domain-specific APIs rather than having everything rely on the grab-bag that is ConfigurationManager. Depending on how those APIs are organised, it should be possible to either not include or let the optimizer remove the unused code, much like it is now.

The third case may be resolved by removing the method entirely (i.e. expand on the work that #10528 started), or by moving the definition to the implementation. For example, values that are read-only in the regular build but set in a factory build only need to have setters in the factory build's implementation. The regular build's implementation can simply not include setters since they aren't needed.

Copy link
Contributor

@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

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

Approving as an intermediate path to splitting configuration manager into more focused intefaces. This is based on expectations of:
(a) size increase is very large only for linux and we understand it (pulls in networking code for things like 'get mac address)
(b) we expect to gain back size splitting into intefaces and removing intermediate layes of config manager.

@yufengwangca
Copy link
Contributor

Yufeng: Currently each platform (other than fake/) already implements their own ConfigurationManagerImpl that overrides a small number of functions from GenericConfigurationManagerImpl, as well as provide a number of functions that GenericConfigurationManagerImpl requires. It should be possible to fold GenericConfigurationManagerImpl into the base class. It may not be necessary depending on future changes, as I think there are a number of methods that won't be used by the SDK and can be made implementation-only, rather than part of the ConfigurationManager interface.

Yes, the intermediate GenericConfigurationManagerImpl layer was introduced only to implement CRTP pattern, we don't need this layer after switching to virtual interface. We can remove this layer as a whole, I am not sure how much memory we can save from this change, but it will make the ConfigurationMgr much easier to understand.

It looks we only need to convert ConfigurationMgr to virtual interface to have type aware API, so the memory increase seems still within our control.

@harimau-qirex harimau-qirex force-pushed the virtual-configuration-manager branch from ebd0ae4 to bef469d Compare October 21, 2021 14:32
harimau-qirex and others added 6 commits October 21, 2021 15:31
To make it possible to set ConfigurationManager at the start of the
program, the next step is to make the interface pure virtual. The
generic implementation also needs to inherit from this interface. Each
platform's implementation is updated to work with the new interface.
The next step to making ConfigurationManager virtual is to remove
the use of Impl() in GenericConfigurationManagerImpl, since the
virtual methods already handle delegating to the inheritor.

Impl() can't be completely removed yet because it's also used for
other functions not part of the ConfigurationManager interface.
…h the new virtual ConfigurationManager interface.
@harimau-qirex harimau-qirex force-pushed the virtual-configuration-manager branch from bef469d to 5506077 Compare October 21, 2021 19:33
@github-actions
Copy link

Size increase report for "gn_qpg-example-build" from 40f6345

File Section File VM
chip-qpg6100-lighting-example.out .text 472 472
chip-qpg6100-lighting-example.out .data 8 8
chip-qpg6100-lighting-example.out .heap 0 -8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.strtab,0,1951
.debug_str,0,870
.symtab,0,720
.text,472,472
.debug_frame,0,88
.debug_aranges,0,40
.data,8,8
.shstrtab,0,-3
.heap,-8,0
.debug_ranges,0,-352
[Unmapped],0,-472
.debug_abbrev,0,-612
.debug_loc,0,-1262
.debug_line,0,-2193
.debug_info,0,-56291

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'


@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 40f6345

File Section File VM
chip-lock.elf rodata 408 408
chip-lock.elf text 348 348
chip-lock.elf device_handles 4 4
chip-shell.elf text 1228 1228
chip-shell.elf rodata 880 880
chip-shell.elf bss 0 20
chip-shell.elf datas 4 4
chip-shell.elf sw_isr_table -4 -4
chip-shell.elf device_handles -12 -12
chip-shell.elf [LOAD #3 [RW]] 0 -20
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.strtab,0,2315
.symtab,0,896
rodata,408,408
text,348,348
.debug_str,0,338
.debug_frame,0,96
.debug_aranges,0,48
device_handles,4,4
.shstrtab,0,-3
.debug_ranges,0,-376
.debug_abbrev,0,-403
.debug_loc,0,-798
.debug_line,0,-1036
.debug_info,0,-53629

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
.strtab,0,5546
.symtab,0,2384
text,1228,1228
rodata,880,880
.debug_str,0,457
.debug_loc,0,411
.debug_frame,0,340
.debug_aranges,0,48
bss,20,0
datas,4,4
.shstrtab,0,2
sw_isr_table,-4,-4
device_handles,-12,-12
[LOAD #3 [RW]],-20,0
.debug_ranges,0,-336
.debug_abbrev,0,-478
.debug_line,0,-820
.debug_info,0,-40118


@github-actions
Copy link

Size increase report for "esp32-example-build" from 40f6345

File Section File VM
chip-all-clusters-app.elf .flash.text 1200 1200
chip-all-clusters-app.elf .flash.rodata 792 792
chip-all-clusters-app.elf .dram0.data 8 16
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.strtab,0,2661
.flash.text,1200,1200
.flash.rodata,792,792
.symtab,0,416
.debug_str,0,337
.debug_frame,0,92
.debug_aranges,0,24
.dram0.data,16,8
.riscv.attributes,0,3
.shstrtab,0,-1
.debug_ranges,0,-240
.debug_loc,0,-1646
[Unmapped],0,-2000
.debug_abbrev,0,-3119
.debug_line,0,-3632
.debug_info,0,-181987


@woody-apple woody-apple merged commit 5018136 into project-chip:master Oct 21, 2021
@harimau-qirex harimau-qirex deleted the virtual-configuration-manager branch October 25, 2021 13:36
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.

9 participants