Skip to content

Comments

[action] [PR:1084] Add pop batch size support for ZMQ Consumer#67

Merged
mssonicbld merged 1 commit intoAzure:202506from
mssonicbld:cherry/msft-202506/1084
Oct 9, 2025
Merged

[action] [PR:1084] Add pop batch size support for ZMQ Consumer#67
mssonicbld merged 1 commit intoAzure:202506from
mssonicbld:cherry/msft-202506/1084

Conversation

@mssonicbld
Copy link
Collaborator

What i did

Add pop batch size support to ZmqConsumerState Table to optimize memory and increase the speed for updating CRM counters/DASH Feedback when applying dash configuration at scale

Example:

Let's say we have a GNMI server which pushed X entries to orchagent. Current logic of ZmqConsumerState table would move X entries to m_toSync map.

Dashorch would create X entries in bulker. However, max_bulk size is often limited (currently 1000) And definitely much less than the size of m_toSync in this scale scenario.

So, effective memory during this time is 2 * X (1 copy in m_toSync + 1 copy in bulker)* size per object until all those entries are applied to ASIC.

  1. With this change, only pop batch size entries are popped out to m_toSync and added to bulker. Thus peak memory utilization is cut in half in case of Dash Scale.

  2. Another side effect of this change is the postprocessing for pop batch size items is done immediately in orchagent and there is no delay on updating CRM or GNMI Feedback loop. If not, post processing starts only after all the entries in m_toSync are applied to syncd which is not capped for current design

How i verified

UT and applying DASH config and making sure everything works

Before the update:

[ RUN      ] ZmqConsumerStateTablePopSize.test
Consumer thread started
Entering select
Producer sent 150 elements
pops: 150
Consumer thread joined
tests/zmq_state_ut.cpp:636: Failure
Expected equality of these values:
 popCount
   Which is: 1
 4
popCount: 1, expected: 4
tests/zmq_state_ut.cpp:639: Failure
Expected equality of these values:
 recvdSizes[i]
   Which is: 150
 expectedSizes[i]
   Which is: 40
recvdSizes[0]: 150, expected: 40
[  FAILED ] ZmqConsumerStateTablePopSize.test (16017 ms)

After the update:

[----------] 1 test from ZmqConsumerStateTablePopSize
[ RUN      ] ZmqConsumerStateTablePopSize.test
Consumer thread started
Entering select
Producer sent 150 elements
pops: 40
Entering select
pops: 40
Entering select
pops: 40
Entering select
pops: 30
Consumer thread joined
[       OK ] ZmqConsumerStateTablePopSize.test (2008 ms)
[----------] 1 test from ZmqConsumerStateTablePopSize (2008 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (2012 ms total)
[  PASSED  ] 1 test.

**What i did**

Add pop batch size support to ZmqConsumerState Table to optimize memory and increase the speed for updating CRM counters/DASH Feedback when applying dash configuration at scale

Example:

Let's say we have a GNMI server which pushed X entries to orchagent. Current logic of ZmqConsumerState table would move X entries to m_toSync map.

Dashorch would create X entries in bulker. However, max_bulk size is often limited (currently 1000) And definitely much less than the size of m_toSync in this scale scenario.

So, effective memory during this time is `2 * X (1 copy in m_toSync + 1 copy in bulker)* size per object `until all those entries are applied to ASIC.

1. With this change, only pop batch size entries are popped out to m_toSync and added to bulker. Thus peak memory utilization is cut in half in case of Dash Scale.

2. Another side effect of this change is the postprocessing for pop batch size  items is done immediately in orchagent and there is no delay on updating CRM or GNMI Feedback loop. If not, post processing starts only after all the entries in m_toSync are applied to syncd which is not capped for current design

**How i verified**

UT and applying DASH config and making sure everything works

Before the update:
```
[ RUN      ] ZmqConsumerStateTablePopSize.test
Consumer thread started
Entering select
Producer sent 150 elements
pops: 150
Consumer thread joined
tests/zmq_state_ut.cpp:636: Failure
Expected equality of these values:
 popCount
   Which is: 1
 4
popCount: 1, expected: 4
tests/zmq_state_ut.cpp:639: Failure
Expected equality of these values:
 recvdSizes[i]
   Which is: 150
 expectedSizes[i]
   Which is: 40
recvdSizes[0]: 150, expected: 40
[  FAILED ] ZmqConsumerStateTablePopSize.test (16017 ms)
```

After the update:
```
[----------] 1 test from ZmqConsumerStateTablePopSize
[ RUN      ] ZmqConsumerStateTablePopSize.test
Consumer thread started
Entering select
Producer sent 150 elements
pops: 40
Entering select
pops: 40
Entering select
pops: 40
Entering select
pops: 30
Consumer thread joined
[       OK ] ZmqConsumerStateTablePopSize.test (2008 ms)
[----------] 1 test from ZmqConsumerStateTablePopSize (2008 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (2012 ms total)
[  PASSED  ] 1 test.
```
@mssonicbld
Copy link
Collaborator Author

Original PR: sonic-net/sonic-swss-common#1084

@mssonicbld
Copy link
Collaborator Author

/azp run

@mssonicbld mssonicbld merged commit 1a31cda into Azure:202506 Oct 9, 2025
5 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