Skip to content

Commit

Permalink
[IM] Update resource minimas for IM as per spec (#16811)
Browse files Browse the repository at this point in the history
* [IM] Update resource limits for read / subscriptions per spec

* Update default config

* Update code and address comments

* Implement tests and some minor fixes

* Address some comments

* Add more tests, add PathsExhausted code

* Try to reduce memory and fix some CI

* Reduce thee memory usage

* Fix CI errors

* Reduce the number of some objects and fix test

* Lift CI timeout

* Update algorithm

* Fix typo

* Update tests

* Remove stress test in Python since subscriptions with min supported paths will always success

* Address comments

* Rename

* Add GetMinSubscriptionsPerFabric

* Update

* Reduce app size

* Address comments

* update CHIP_IM_MAX_NUM_READ_HANDLER

* Fix CI, Fix logic for evicting over quota subscriptions

* Fix CI

* Address comments

* Address comments

* Reduce size
  • Loading branch information
erjiaqing authored Apr 25, 2022
1 parent 0cbfaec commit 077e44e
Show file tree
Hide file tree
Showing 43 changed files with 956 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:
jobs:
build_linux_gcc_debug:
name: Build on Linux (gcc_debug)
timeout-minutes: 65
timeout-minutes: 85

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cirque.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
-- ./gn_build.sh \
chip_build_tests=false \
chip_enable_wifi=false \
chip_im_force_fabric_quota_check=true \
enable_host_gcc_build=true \
enable_host_gcc_mbedtls_build=false \
enable_host_clang_build=false \
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ jobs:
scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-all-clusters-${BUILD_VARIANT} \
--target linux-x64-all-clusters-${BUILD_VARIANT}-test \
--target linux-x64-python-bindings \
build \
--copy-artifacts-to objdir-clone \
"
- name: Run Tests
timeout-minutes: 30
run: |
scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang/chip-all-clusters-app --factoryreset --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"'
scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"'
- name: Uploading core files
uses: actions/upload-artifact@v2
if: ${{ failure() }} && ${{ !env.ACT }}
Expand Down Expand Up @@ -352,14 +352,14 @@ jobs:
scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target darwin-x64-all-clusters-${BUILD_VARIANT} \
--target darwin-x64-all-clusters-${BUILD_VARIANT}-test \
build \
--copy-artifacts-to objdir-clone \
"
- name: Run Tests
timeout-minutes: 30
run: |
scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/darwin-x64-all-clusters-no-ble-no-wifi-tsan-clang/chip-all-clusters-app --factoryreset --app-args "--discriminator 3840 --interface-id -1" --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"'
scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/darwin-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 3840 --interface-id -1" --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"'
- name: Uploading core files
uses: actions/upload-artifact@v2
if: ${{ failure() }} && ${{ !env.ACT }}
Expand Down
11 changes: 7 additions & 4 deletions config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define CHIP_CONFIG_EVENT_LOGGING_EXTERNAL_EVENT_SUPPORT 1

// Uncomment this for a large Tunnel MTU.
//#define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000)
// #define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000)

// Enable support functions for parsing command-line arguments
#define CHIP_CONFIG_ENABLE_ARG_PARSER 1
Expand Down Expand Up @@ -77,10 +77,13 @@
//
// Default of 8 ECs is not sufficient for some of the unit tests
// that try to validate multiple simultaneous interactions.
// In tests like TestReadHandler_MultipleSubscriptions, we are trying to issue as many read / subscription requests as possible in
// parallel. Since the default config says we support 16 fabrics, and we will have 4 read handlers for each fabric (3 subscriptions
// + 1 reserved for read) that is read transactions in parallel. Since the report handlers are allocated on the heap, we will issue
// 65 requests (the TestReadHandler_MultipleSubscriptions will issue CHIP_IM_MAX_NUM_READ_HANDLER + 1 subscriptions to verify heap
// allocation logic) in total and that is 130 ECs. Round this up to 150 ECs
//
#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 24

#define CHIP_IM_MAX_NUM_READ_HANDLER 8
#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 150

#define CONFIG_IM_BUILD_FOR_UNIT_TEST 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down Expand Up @@ -125,4 +125,18 @@

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 1

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 1

#endif // CHIP_PROJECT_CONFIG_H
16 changes: 15 additions & 1 deletion examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
Expand Down Expand Up @@ -138,6 +138,20 @@
*/
#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
Expand Down
16 changes: 0 additions & 16 deletions examples/lighting-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@
* The following definitions sets the maximum number of corresponding interaction model object pool size.
*
* * #CHIP_IM_MAX_NUM_COMMAND_HANDLER
* * #CHIP_IM_MAX_NUM_READ_HANDLER
* * #CHIP_IM_MAX_REPORTS_IN_FLIGHT
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
* * #CHIP_IM_MAX_NUM_WRITE_HANDLER
* * #CHIP_IM_MAX_NUM_WRITE_CLIENT
*
Expand All @@ -148,27 +146,13 @@
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_READ_HANDLER
*
* @brief Defines the maximum number of ReadHandler, limits the number of active read transactions on server.
*/
#define CHIP_IM_MAX_NUM_READ_HANDLER 3

/**
* @def CHIP_IM_MAX_REPORTS_IN_FLIGHT
*
* @brief Defines the maximum number of Reports, limits the traffic of read and subscription transactions.
*/
#define CHIP_IM_MAX_REPORTS_IN_FLIGHT 2

/**
* @def CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
*
* @brief Defines the maximum number of path objects, limits the number of attributes being read or subscribed at the same time.
*/
#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS 9

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down Expand Up @@ -125,4 +125,18 @@

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2

#endif // CHIP_PROJECT_CONFIG_H
16 changes: 15 additions & 1 deletion examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
Expand Down Expand Up @@ -156,3 +156,17 @@
#endif // BUILD_RELEASE

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 1

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2
16 changes: 0 additions & 16 deletions examples/lock-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@
* The following definitions sets the maximum number of corresponding interaction model object pool size.
*
* * #CHIP_IM_MAX_NUM_COMMAND_HANDLER
* * #CHIP_IM_MAX_NUM_READ_HANDLER
* * #CHIP_IM_MAX_REPORTS_IN_FLIGHT
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
* * #CHIP_IM_MAX_NUM_WRITE_HANDLER
* * #CHIP_IM_MAX_NUM_WRITE_CLIENT
*
Expand All @@ -146,27 +144,13 @@
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_READ_HANDLER
*
* @brief Defines the maximum number of ReadHandler, limits the number of active read transactions on server.
*/
#define CHIP_IM_MAX_NUM_READ_HANDLER 3

/**
* @def CHIP_IM_MAX_REPORTS_IN_FLIGHT
*
* @brief Defines the maximum number of Reports, limits the traffic of read and subscription transactions.
*/
#define CHIP_IM_MAX_REPORTS_IN_FLIGHT 2

/**
* @def CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
*
* @brief Defines the maximum number of path objects, limits the number of attributes being read or subscribed at the same time.
*/
#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS 9

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down Expand Up @@ -135,4 +135,18 @@
#define CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE chip::Profiles::DataManagement::Debug
#endif // BUILD_RELEASE

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2

#endif // CHIP_PROJECT_CONFIG_H
16 changes: 0 additions & 16 deletions examples/persistent-storage/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@
* The following definitions sets the maximum number of corresponding interaction model object pool size.
*
* * #CHIP_IM_MAX_NUM_COMMAND_HANDLER
* * #CHIP_IM_MAX_NUM_READ_HANDLER
* * #CHIP_IM_MAX_REPORTS_IN_FLIGHT
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
* * #CHIP_IM_MAX_NUM_WRITE_HANDLER
* * #CHIP_IM_MAX_NUM_WRITE_CLIENT
*
Expand All @@ -144,27 +142,13 @@
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_READ_HANDLER
*
* @brief Defines the maximum number of ReadHandler, limits the number of active read transactions on server.
*/
#define CHIP_IM_MAX_NUM_READ_HANDLER 3

/**
* @def CHIP_IM_MAX_REPORTS_IN_FLIGHT
*
* @brief Defines the maximum number of Reports, limits the traffic of read and subscription transactions.
*/
#define CHIP_IM_MAX_REPORTS_IN_FLIGHT 2

/**
* @def CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
*
* @brief Defines the maximum number of path objects, limits the number of attributes being read or subscribed at the same time.
*/
#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS 9

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down Expand Up @@ -128,4 +128,24 @@

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*
* TODO: (#17080) 1 should be OK since almost all commands are synchronous, should be some larger number after we resolved the issue
* of the large memory footprint of ReadHandler.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 1

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*
* TODO: (#17080) 1 should be OK since most write requests can be synchronous (not chunked), should be some larger number after we
* resolved the issue of the large memory footprint of ReadHandler.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 1

#endif // CHIP_PROJECT_CONFIG_H
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down Expand Up @@ -128,4 +128,18 @@

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2

/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2

#endif // CHIP_PROJECT_CONFIG_H
Loading

0 comments on commit 077e44e

Please sign in to comment.