Skip to content

[code sync] Merge code from sonic-net/sonic-platform-daemons:202605 to 202608 - #79

Merged
mssonicbld merged 3 commits into
Azure:202608from
mssonicbld:sonicbld/202608-merge
Jul 30, 2026
Merged

[code sync] Merge code from sonic-net/sonic-platform-daemons:202605 to 202608#79
mssonicbld merged 3 commits into
Azure:202608from
mssonicbld:sonicbld/202608-merge

Conversation

@mssonicbld

Copy link
Copy Markdown
Collaborator
* 30f2f0b - (origin/202605, test, 202607) Adjust select timeouts during port update handling to allow for faster transceiver DOM polling (#864) (2026-07-29) [mssonicbld]
* 70e7844 - [cmis] Fix issue: Potential race condition between split ports while doing DPSM (#863) (2026-07-29) [mssonicbld]<br>```

mssonicbld and others added 3 commits July 29, 2026 16:15
…doing DPSM (#863)

## Why I did it

Fix issue: sonic-net/sonic-buildimage#27373

CMIS datapath deinitialization should follow the expected software deinit sequence. When forcing a datapath re-init because `host_tx_ready` is false or the port is administratively down, xcvrd should request datapath deinit before disabling media-side Tx.

This keeps the forced re-init path consistent with the normal `CMIS_STATE_DP_DEINIT` flow and CMIS datapath state machine behavior.

## How I did it

Updated the forced re-init path in `cmis_manager_task.py` to call `set_datapath_deinit()` before `tx_disable_channel()`.

Updated the existing `test_CmisManagerTask_task_worker_host_tx_ready_false_to_true` unit test to record the mock API call order and verify that datapath deinit is issued before Tx disable.

## How to verify it

Run the xcvrd unit test:

```bash
python3 -m pytest sonic-xcvrd/tests/test_xcvrd.py -k test_CmisManagerTask_task_worker_host_tx_ready_false_to_true

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
…r transceiver DOM polling (#864)

<!-- Provide a general summary of your changes in the Title above -->

#### Description
This PR optimizes the DOM (Digital Optical Monitoring) polling loop in xcvrd by improving port update event handling and reducing unnecessary wait times. The changes include:

1. **Refactored port update handling** - Extracted port update event processing into a dedicated `check_port_update()` method for better code organization and reusability
2. **Optimized timeout strategy** - Introduced two-tier timeout mechanism:
 - 1000ms timeout when waiting for port updates before DOM polling begins and after when it completes until the next polling cycle
 - 100ms timeout during DOM polling to minimize delays while still handling port events
3. **Improved loop structure** - Restructured the main loop to handle port updates before entering the DOM polling phase, preventing unnecessary blocking
4. **Added comprehensive unit tests** - Created tests covering various scenarios including multiple ports, timing edge cases, and stop event handling

fixes #759 and builds on sonic-net/sonic-platform-daemons#757

#### Motivation and Context
Before the change, the DOM monitoring loop would wait up to 1 second (`SELECT_TIMEOUT_MSECS`) for port update events during each iteration of the physical port loop. This caused significant delays in DOM data collection, especially on systems with many ports.

**Problem:** With the 1-second timeout being called for every physical port, the DOM polling could take an excessive amount of time to complete, delaying DOM polling updates.

**Solution:** By separating port update handling from DOM polling and using a shorter 100ms timeout during the polling phase, the loop can complete much faster while still being responsive to port change events. The 1-second timeout is only used when explicitly waiting for port updates before starting the next DOM polling cycle.

#### How Has This Been Tested?
1. **Unit Tests Added** - Comprehensive test coverage for the new `check_port_update()` method including:
 - Scenario with no link change affected ports
 - Link change affected port with past timestamp (should trigger immediate update)
 - Link change affected port with future timestamp (should defer update)
 - Multiple ports with mixed ready/not-ready states
 - Stop event handling during processing

2. **CPU usage profiling**: Measured for 10 minutes after restarting `xcvrd` on a switch fully populated with optical transceivers.
- Before the change (includes changes from sonic-net/sonic-platform-daemons#757)
<img width="937" height="257" alt="image" src="https://github.com/user-attachments/assets/224dca27-c0fa-4059-b7b1-fdcd9a4ed66e" />
- After the change
<img width="934" height="249" alt="image" src="https://github.com/user-attachments/assets/8efa3d40-1e25-45c8-a48a-088d55ff34c3" />

The CPU usage is slightly higher during active polling as it spends less time waiting (100ms) between interfaces and then the loop spends time waiting for port change updates in 1s chunks.

3. **Measuring actual DOM update times**
- Before change: We are not able to poll every 60 seconds (takes 90 sec+) on a switch fully populated with optical transceivers
```
$ while true; do sonic-db-dump -n STATE_DB -y -k "TRANSCEIVER_DOM_SENSOR|Ethernet112" | grep last_update_time; sleep 10; done | uniq
 "last_update_time": "Tue Feb 24 19:25:57 2026",
 "last_update_time": "Tue Feb 24 19:27:32 2026",
 "last_update_time": "Tue Feb 24 19:29:06 2026",
 "last_update_time": "Tue Feb 24 19:30:40 2026",
 "last_update_time": "Tue Feb 24 19:32:13 2026",
 "last_update_time": "Tue Feb 24 19:33:47 2026",
```
- After change: Updates happen every 60 seconds for a specified interface
```
$ while true; do sonic-db-dump -n STATE_DB -y -k "TRANSCEIVER_DOM_SENSOR|Ethernet112" | grep last_update_time; sleep 10; done | uniq
 "last_update_time": "Tue Feb 24 19:17:09 2026",
 "last_update_time": "Tue Feb 24 19:18:10 2026",
 "last_update_time": "Tue Feb 24 19:19:10 2026",
 "last_update_time": "Tue Feb 24 19:20:10 2026",
 "last_update_time": "Tue Feb 24 19:21:11 2026",
 "last_update_time": "Tue Feb 24 19:22:11 2026",
```

#### Additional Information (Optional)
**Key Technical Changes:**
- New constants: `PORT_UPDATE_EVENT_SELECT_TIMEOUT_MSECS` (1000ms) and `PORT_UPDATE_EVENT_SELECT_TIMEOUT_FAST_MSECS` (100ms)
- Modified `PortChangeObserver.handle_port_update_event()` to accept a configurable timeout parameter
- The periodic update interval calculation now uses `dom_loop_start_time` to maintain consistent intervals regardless of loop execution time

**Backward Compatibility:** This change is fully backward compatible and does not affect the external API or configuration.

#### Tested branch
- [x] master
- [x] 202605: already in Nexthop's internal 202605 branch

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
@mssonicbld
mssonicbld merged commit a1d87ae into Azure:202608 Jul 30, 2026
2 checks passed
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.

1 participant