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

Separate System::Layer and Timer into per-implementation files. #8800

Merged
merged 11 commits into from
Aug 11, 2021

Conversation

kpschoedel
Copy link
Contributor

@kpschoedel kpschoedel commented Aug 4, 2021

Problem

Various implementations of System::Layer are provided by #if sections,
which prevents mock versions for testing and out-of-tree platform
implementations.

Change overview

Split platform #if sections of System::Layer and System::Timer
into separate WatchableEventManager implementations.

This change does for timers what PR #6561 did for socket I/O events.
The intent is that the public WatchableEventManager interface here
will become pure virtual methods of System::Layer, and the various
versions of WatchableEventManager will become its implementations.

System::Timer remains as an Object-pool based utility class for
implementing the Timer API.

Part of issue #5556 rework system layer event loop
Part of issue #7715 Virtualize System and Inet interfaces
Fixes #7757 Integrate timer platform details with WatchableEventManager.

Testing

Relying on CI in general, since no externally visible functionality
should have changed. Sanity-checked the libevent implementation (not in
CI) using chip-tool.

#### Problem

Various implementations of System::Layer are provided by `#if` sections,
which prevents mock versions for testing and out-of-tree platform
implementations.

#### Change overview

Split platform `#if` sections of `System::Layer` and `System::Timer`
into separate `WatchableEventManager` implementations.

This change does for timers what PR project-chip#6561 did for socket I/O events.
The intent is that the public `WatchableEventManager` interface here
will become pure virtual methods of `System::Layer`, and the various
versions of `WatchableEventManager` will become its implementations.

`System::Timer` remains as an `Object`-pool based utility class for
implementing the Timer API.

- Make `Timer` list not LwIP-specific, mutex it, and use it in preference
  to iterating through the entire pool.
- Move `IsEarlier` from `Timer` to `Clock`.
- Fix dual definitions of `Clock::Platform` functions on Linux.

#### Testing

Relying on CI in general, since no externally visible functionality
should have changed. Sanity-checked the libevent implementation (not in
CI) using chip-tool.
Copy link
Contributor

@mspang mspang left a comment

Choose a reason for hiding this comment

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

There seems to be some debug logs left in here.

src/system/WatchableEventManagerSelect.cpp Outdated Show resolved Hide resolved
- add config flag CHIP_SYSTEM_CONFIG_USE_TIMER_POOL
- use std::lock_guard rather than inventing ScopedMutexLock
- rename mWatchableEvents and WatchableEvents()
@github-actions
Copy link

github-actions bot commented Aug 9, 2021

Size increase report for "esp32-example-build" from f446fd2

File Section File VM
chip-shell.elf .flash.text 328 328
chip-shell.elf .dram0.bss 0 88
chip-shell.elf .iram0.text 52 52
chip-lock-app.elf .flash.text 240 240
chip-lock-app.elf .dram0.bss 0 88
chip-lock-app.elf .iram0.text 52 52
chip-bridge-app.elf .flash.text 292 292
chip-bridge-app.elf .dram0.bss 0 88
chip-bridge-app.elf .iram0.text 52 52
chip-temperature-measurement-app.elf .flash.text 220 220
chip-temperature-measurement-app.elf .dram0.bss 0 96
chip-temperature-measurement-app.elf .iram0.text 40 40
chip-temperature-measurement-app.elf .flash.rodata 8 8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-ipv6only-app.elf and ./pull_artifact/chip-ipv6only-app.elf:

sections,vmsize,filesize
.debug_info,0,22975
.debug_str,0,7971
.debug_line,0,865
.debug_abbrev,0,756
.debug_loc,0,-3

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

sections,vmsize,filesize
.debug_info,0,423923
.debug_line,0,33627
.debug_abbrev,0,28574
.debug_str,0,5381
.debug_loc,0,1543
.strtab,0,693
.debug_ranges,0,352
.debug_frame,0,344
.flash.text,328,328
.symtab,0,192
.debug_aranges,0,152
.dram0.bss,88,0
.xt.prop._ZN4chip6System5Mutex6UnlockEv,0,76
.xt.prop._ZNSt8_Rb_treeIhSt4pairIKhN4chip18OptionalQRCodeInfoEESt10_Select1stIS4_ESt4lessIhESaIS4_EE14_M_create_nodeIJRKS4_EEEPSt13_Rb_tree_nodeIS4_EDpOT_$isra$67,0,76
.iram0.text,52,52
.shstrtab,0,47
[1 Others],0,40
.xt.lit.chipDie,0,-48
.xt.prop._ZNSt8_Rb_treeIhSt4pairIKhN4chip18OptionalQRCodeInfoEESt10_Select1stIS4_ESt4lessIhESaIS4_EE14_M_create_nodeIJRKS4_EEEPSt13_Rb_tree_nodeIS4_EDpOT_$isra$68,0,-76
.xt.prop.chipDie,0,-76
[Unmapped],0,-380

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize
.debug_info,0,22975
.debug_str,0,7983
.debug_line,0,865
.debug_abbrev,0,756
.debug_loc,0,5

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

sections,vmsize,filesize
.debug_info,0,1749794
.debug_abbrev,0,81030
.debug_line,0,69181
.debug_str,0,8991
.debug_loc,0,1716
.strtab,0,658
.debug_ranges,0,328
.debug_frame,0,280
.flash.text,240,240
.debug_aranges,0,112
.symtab,0,112
.xt.prop._ZSt34__uninitialized_move_if_noexcept_aIPN4chip18OptionalQRCodeInfoES2_SaIS1_EET0_T_S5_S4_RT1_$isra$130,0,100
.dram0.bss,88,0
.xt.prop._ZNSt8_Rb_treeIhSt4pairIKhN4chip18OptionalQRCodeInfoEESt10_Select1stIS4_ESt4lessIhESaIS4_EE14_M_create_nodeIJRKS4_EEEPSt13_Rb_tree_nodeIS4_EDpOT_$isra$72,0,76
.iram0.text,52,52
[1 Others],0,-34
.xt.lit.chipDie,0,-48
.xt.prop._ZNSt8_Rb_treeIhSt4pairIKhN4chip18OptionalQRCodeInfoEESt10_Select1stIS4_ESt4lessIhESaIS4_EE14_M_create_nodeIJRKS4_EEEPSt13_Rb_tree_nodeIS4_EDpOT_$isra$73,0,-76
.xt.prop.chipDie,0,-76
.xt.prop._ZSt34__uninitialized_move_if_noexcept_aIPN4chip18OptionalQRCodeInfoES2_SaIS1_EET0_T_S5_S4_RT1_$isra$138,0,-100
[Unmapped],0,-292

Comparing ./master_artifact/chip-bridge-app.elf and ./pull_artifact/chip-bridge-app.elf:

sections,vmsize,filesize
.debug_info,0,761304
.debug_line,0,53458
.debug_abbrev,0,47867
.debug_str,0,4986
.debug_loc,0,1433
.strtab,0,658
.debug_ranges,0,328
.flash.text,292,292
.debug_frame,0,280
.debug_aranges,0,112
.symtab,0,112
.dram0.bss,88,0
.iram0.text,52,52
.shstrtab,0,-34
.xt.lit.chipDie,0,-48
.xt.prop.chipDie,0,-76
[Unmapped],0,-344

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

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: integer overflow

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize
.debug_info,0,31204
.debug_str,0,4454
.debug_line,0,2446
.debug_abbrev,0,2129
.debug_loc,0,-5

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
.debug_info,0,743859
.debug_line,0,52029
.debug_abbrev,0,46769
.debug_str,0,4987
.debug_loc,0,1680
.strtab,0,658
.debug_ranges,0,312
.debug_frame,0,280
.flash.text,220,220
.debug_aranges,0,112
.symtab,0,112
.dram0.bss,96,0
.iram0.text,40,40
.flash.rodata,8,8
.shstrtab,0,-30
.xt.lit.chipDie,0,-48
.xt.prop.chipDie,0,-76
[Unmapped],0,-268


@github-actions
Copy link

github-actions bot commented Aug 9, 2021

Size increase report for "nrfconnect-example-build" from f446fd2

File Section File VM
chip-shell.elf text 212 212
chip-shell.elf bss 0 152
chip-shell.elf [LOAD #3 [RW]] 0 8
chip-shell.elf device_handles -4 -4
chip-lock.elf text 184 184
chip-lock.elf bss 0 160
chip-lock.elf device_handles 8 8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

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

sections,vmsize,filesize
.debug_info,0,341594
.debug_line,0,23940
.debug_abbrev,0,12338
.debug_str,0,2381
.debug_loc,0,1643
.strtab,0,448
.debug_ranges,0,424
.debug_frame,0,216
text,212,212
bss,152,0
.symtab,0,144
.debug_aranges,0,88
[LOAD #3 [RW]],8,0
device_handles,-4,-4

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

sections,vmsize,filesize
.debug_info,0,608678
.debug_line,0,43797
.debug_abbrev,0,21729
.debug_str,0,2381
.debug_loc,0,1847
.strtab,0,465
.debug_ranges,0,424
.debug_frame,0,216
text,184,184
bss,160,0
.symtab,0,144
.debug_aranges,0,88
device_handles,8,8
.shstrtab,0,-1


@github-actions
Copy link

github-actions bot commented Aug 9, 2021

Size increase report for "gn_qpg-example-build" from f446fd2

File Section File VM
chip-qpg6100-lighting-example.out .text 336 336
chip-qpg6100-lighting-example.out .bss 0 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.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'

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

sections,vmsize,filesize
.debug_info,0,509261
.debug_line,0,34038
.debug_abbrev,0,21517
.debug_str,0,2691
.debug_loc,0,1525
.strtab,0,744
.text,336,336
.symtab,0,320
.debug_frame,0,276
.debug_ranges,0,224
.debug_aranges,0,120
.bss,8,0
.heap,-8,0
[Unmapped],0,-336


@mspang
Copy link
Contributor

mspang commented Aug 10, 2021

@woody-apple woody-apple merged commit 2d103c8 into project-chip:master Aug 11, 2021
@kpschoedel kpschoedel deleted the x7725-system-event-5 branch August 11, 2021 13:11
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this pull request Aug 13, 2021
#### Problem

As of project-chip#8800, the `System::Timer` class is no longer an inherent part of
the `System::Layer` timer implementation; it is a utility class that can
be used by implementations. However, project-chip#8800 did not include any example
of this kind of use, and did not adequately document `System::Timer`.

#### Change overview

- The libevent implementation no longer uses `System::Timer`.
- Added documentation for `System::Timer`.
- Moved documentation for `System::Layer` into the header.

#### Testing

Manual verification using chip-tool. The libevent implementation is
currently provided only as an illustrative example, and is not exercised
in CI.
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this pull request Aug 13, 2021
#### Problem

As of project-chip#8800, the `System::Timer` class is no longer an inherent part of
the `System::Layer` timer implementation; it is a utility class that can
be used by implementations. However, project-chip#8800 did not include any example
of this kind of use, and did not adequately document `System::Timer`.

#### Change overview

- The libevent implementation no longer uses `System::Timer`.
- Added documentation for `System::Timer`.
- Moved documentation for `System::Layer` into the header.

#### Testing

Manual verification using chip-tool. The libevent implementation is
currently provided only as an illustrative example, and is not exercised
in CI.
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
…ect-chip#8800)

* Separate System::Layer and Timer into per-implementation files.

#### Problem

Various implementations of System::Layer are provided by `#if` sections,
which prevents mock versions for testing and out-of-tree platform
implementations.

#### Change overview

Split platform `#if` sections of `System::Layer` and `System::Timer`
into separate `WatchableEventManager` implementations.

This change does for timers what PR project-chip#6561 did for socket I/O events.
The intent is that the public `WatchableEventManager` interface here
will become pure virtual methods of `System::Layer`, and the various
versions of `WatchableEventManager` will become its implementations.

`System::Timer` remains as an `Object`-pool based utility class for
implementing the Timer API.

- Make `Timer` list not LwIP-specific, mutex it, and use it in preference
  to iterating through the entire pool.
- Move `IsEarlier` from `Timer` to `Clock`.
- Fix dual definitions of `Clock::Platform` functions on Linux.

#### Testing

Relying on CI in general, since no externally visible functionality
should have changed. Sanity-checked the libevent implementation (not in
CI) using chip-tool.

* rebase and regen zap

* Remove obsolete TODO.

* restyle

* remove leftover debug logging

* restyle

* convert outdated ChipError::FormatError()

* review

- add config flag CHIP_SYSTEM_CONFIG_USE_TIMER_POOL
- use std::lock_guard rather than inventing ScopedMutexLock
- rename mWatchableEvents and WatchableEvents()
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.

(#5556): Integrate timer platform details with WatchableEventManager.
6 participants