Skip to content

Conversation

@bzbarsky-apple
Copy link
Contributor

This gives better set-insertion behavior.

Testing

Manual measurements of the number of isEqual calls that happen during set operations.

This gives better set-insertion behavior.
Copilot AI review requested due to automatic review settings October 9, 2025 16:12
@bzbarsky-apple bzbarsky-apple requested a review from a team as a code owner October 9, 2025 16:12
@github-actions github-actions bot added the darwin label Oct 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves hash function implementations for various path objects in the Matter framework to provide better set-insertion behavior. The changes replace simple bit-shifting hash calculations with a centralized, more sophisticated hash function.

  • Introduces a new HashPath utility function that provides optimized hash calculations for different NSUInteger sizes
  • Replaces existing hash implementations across multiple path classes to use the centralized function
  • Updates bit allocation strategy to reduce hash collisions

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

PR #41368: Size comparison from a6bb081 to 0a2c56c

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section a6bb081 0a2c56c change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105382 1105382 0 0.0
RAM 178754 178754 0 0.0
bl702 lighting-app bl702+eth FLASH 659886 659886 0 0.0
RAM 134817 134817 0 0.0
bl702+wifi FLASH 835954 835954 0 0.0
RAM 124301 124301 0 0.0
bl706+mfd+rpc+littlefs FLASH 1069098 1069098 0 0.0
RAM 117133 117133 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899312 899312 0 0.0
RAM 105476 105476 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981860 981860 0 0.0
RAM 109628 109628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 769420 769420 0 0.0
RAM 103200 103200 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 781048 781048 0 0.0
RAM 108360 108360 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 727052 727052 0 0.0
RAM 97268 97268 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 711504 711504 0 0.0
RAM 97484 97484 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554146 554146 0 0.0
RAM 204976 204976 0 0.0
lock CC3235SF_LAUNCHXL FLASH 586862 586862 0 0.0
RAM 205208 205208 0 0.0
efr32 lock-app BRD4187C FLASH 961160 961160 0 0.0
RAM 126224 126224 0 0.0
BRD4338a FLASH 755896 755888 -8 -0.0
RAM 255500 255500 0 0.0
window-app BRD4187C FLASH 1055500 1055500 0 0.0
RAM 122420 122420 0 0.0
esp32 all-clusters-app c3devkit DRAM 103016 103016 0 0.0
FLASH 1789364 1789364 0 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 929224 929224 0 0.0
RAM 160987 160987 0 0.0
nxp contact mcxw71+release FLASH 691792 691792 0 0.0
RAM 61440 61440 0 0.0
lighting mcxw71+release FLASH 723360 723360 0 0.0
RAM 68092 68092 0 0.0
lock mcxw71+release FLASH 770584 770584 0 0.0
RAM 61804 61804 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1671220 1671220 0 0.0
RAM 213052 213052 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1589540 1589540 0 0.0
RAM 210332 210332 0 0.0
light cy8ckit_062s2_43012 FLASH 1456356 1456356 0 0.0
RAM 197056 197056 0 0.0
lock cy8ckit_062s2_43012 FLASH 1488684 1488684 0 0.0
RAM 224768 224768 0 0.0
qpg lighting-app qpg6200+debug FLASH 835392 835392 0 0.0
RAM 127604 127604 0 0.0
lock-app qpg6200+debug FLASH 772156 772156 0 0.0
RAM 118572 118572 0 0.0
realtek light-switch-app rtl8777g FLASH 705376 705376 0 0.0
RAM 106776 106776 0 0.0
lighting-app rtl8777g FLASH 756576 756576 0 0.0
RAM 127132 127132 0 0.0
stm32 light STM32WB5MM-DK FLASH 469076 469076 0 0.0
RAM 141200 141200 0 0.0
telink bridge-app tl7218x FLASH 708446 708446 0 0.0
RAM 90356 90356 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795978 795978 0 0.0
RAM 40908 40908 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787174 787174 0 0.0
RAM 93552 93552 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713980 713980 0 0.0
RAM 51724 51724 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 747284 747284 0 0.0
RAM 70772 70772 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 724136 724136 0 0.0
RAM 34472 34472 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 601402 601402 0 0.0
RAM 108600 108600 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819794 819798 4 0.0
RAM 91948 91948 0 0.0

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the hash implementations for various path objects, which should lead to better performance in hash-based collections. The introduction of a centralized HashPath function is a good approach. I've found a couple of issues: one is a bug in the new HashPath function that could lead to hash collisions, and the other is an inconsistency in -[MTRClusterPath hash] which doesn't use the new helper function. My review includes suggestions to fix these issues to make the hashing more robust and consistent.

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.95%. Comparing base (a6bb081) to head (aa6356d).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41368      +/-   ##
==========================================
- Coverage   50.95%   50.95%   -0.01%     
==========================================
  Files        1378     1378              
  Lines      100614   100643      +29     
  Branches    13025    13028       +3     
==========================================
+ Hits        51272    51283      +11     
- Misses      49342    49360      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

PR #41368: Size comparison from a6bb081 to aa6356d

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section a6bb081 aa6356d change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105382 1105398 16 0.0
RAM 178754 178754 0 0.0
bl702 lighting-app bl702+eth FLASH 659886 659886 0 0.0
RAM 134817 134817 0 0.0
bl702+wifi FLASH 835954 835970 16 0.0
RAM 124301 124301 0 0.0
bl706+mfd+rpc+littlefs FLASH 1069098 1069106 8 0.0
RAM 117133 117133 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899312 899320 8 0.0
RAM 105476 105476 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981860 981868 8 0.0
RAM 109628 109628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 769420 769396 -24 -0.0
RAM 103200 103200 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 781048 781040 -8 -0.0
RAM 108360 108360 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 727052 727028 -24 -0.0
RAM 97268 97268 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 711504 711496 -8 -0.0
RAM 97484 97484 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554146 554146 0 0.0
RAM 204976 204976 0 0.0
lock CC3235SF_LAUNCHXL FLASH 586862 586862 0 0.0
RAM 205208 205208 0 0.0
efr32 lock-app BRD4187C FLASH 961160 961136 -24 -0.0
RAM 126224 126224 0 0.0
BRD4338a FLASH 755896 755872 -24 -0.0
RAM 255500 255500 0 0.0
window-app BRD4187C FLASH 1055500 1055476 -24 -0.0
RAM 122420 122420 0 0.0
esp32 all-clusters-app c3devkit DRAM 103016 103016 0 0.0
FLASH 1789364 1789684 320 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 929224 929632 408 0.0
RAM 160987 160987 0 0.0
nxp contact mcxw71+release FLASH 691792 691768 -24 -0.0
RAM 61440 61440 0 0.0
lighting mcxw71+release FLASH 723360 723336 -24 -0.0
RAM 68092 68092 0 0.0
lock mcxw71+release FLASH 770584 770560 -24 -0.0
RAM 61804 61804 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1671220 1671708 488 0.0
RAM 213052 213052 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1589540 1589524 -16 -0.0
RAM 210332 210332 0 0.0
light cy8ckit_062s2_43012 FLASH 1456356 1456340 -16 -0.0
RAM 197056 197056 0 0.0
lock cy8ckit_062s2_43012 FLASH 1488684 1488668 -16 -0.0
RAM 224768 224768 0 0.0
qpg lighting-app qpg6200+debug FLASH 835392 835384 -8 -0.0
RAM 127604 127604 0 0.0
lock-app qpg6200+debug FLASH 772156 772132 -24 -0.0
RAM 118572 118572 0 0.0
realtek light-switch-app rtl8777g FLASH 705376 705360 -16 -0.0
RAM 106776 106776 0 0.0
lighting-app rtl8777g FLASH 756576 756560 -16 -0.0
RAM 127132 127132 0 0.0
stm32 light STM32WB5MM-DK FLASH 469076 469028 -48 -0.0
RAM 141200 141200 0 0.0
telink bridge-app tl7218x FLASH 708446 708400 -46 -0.0
RAM 90356 90356 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795978 795932 -46 -0.0
RAM 40908 40908 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787174 787128 -46 -0.0
RAM 93552 93552 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713980 713934 -46 -0.0
RAM 51724 51724 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 747284 747238 -46 -0.0
RAM 70772 70772 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 724136 724090 -46 -0.0
RAM 34472 34472 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 601402 601358 -44 -0.0
RAM 108600 108600 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819794 819752 -42 -0.0
RAM 91948 91948 0 0.0

@mergify mergify bot merged commit d890ac2 into project-chip:master Oct 10, 2025
74 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in [Platform] Darwin Oct 10, 2025
@bzbarsky-apple bzbarsky-apple deleted the better-hashing branch October 10, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants