Skip to content

Optimize shm watchdog storage #1869

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

Merged

Conversation

yellowhatter
Copy link
Contributor

@yellowhatter yellowhatter commented Apr 2, 2025

  • Improves SHM performance: around 600k msgs\sec added in SHM mode (2.4 -> 3M)
  • Fixes issue with lack of metadata cells: make metadata segment growing to fix arena memory utilization issue (when there is memory in arena, but no more metadata cells)
  • make SHM buffer own it's abstract shared memory segment to enforce it's lifetime

@yellowhatter yellowhatter added the enhancement Existing things could work better label Apr 2, 2025
@yellowhatter yellowhatter self-assigned this Apr 2, 2025
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 82.90909% with 47 lines in your changes missing coverage. Please review.

Project coverage is 70.91%. Comparing base (b33ddc3) to head (0757c3d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
commons/zenoh-shm/src/api/provider/shm_provider.rs 53.57% 13 Missing ⚠️
commons/zenoh-shm/src/metadata/descriptor.rs 71.05% 11 Missing ⚠️
commons/zenoh-shm/src/api/common/types.rs 52.94% 8 Missing ⚠️
commons/zenoh-shm/src/api/client_storage/mod.rs 50.00% 3 Missing ⚠️
commons/zenoh-shm/src/watchdog/periodic_task.rs 84.21% 3 Missing ⚠️
commons/zenoh-shm/src/metadata/storage.rs 88.88% 2 Missing ⚠️
commons/zenoh-shm/src/metadata/subscription.rs 87.50% 2 Missing ⚠️
commons/zenoh-shm/src/watchdog/confirmator.rs 96.29% 2 Missing ⚠️
commons/zenoh-shm/src/api/provider/chunk.rs 0.00% 1 Missing ⚠️
commons/zenoh-shm/src/lib.rs 75.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1869      +/-   ##
==========================================
- Coverage   71.03%   70.91%   -0.12%     
==========================================
  Files         364      365       +1     
  Lines       61519    61615      +96     
==========================================
- Hits        43699    43695       -4     
- Misses      17820    17920     +100     

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

- Optimize global segment ID generation and indexing
- Optimize some structures on stack
- Mutex -> RWLock
@yellowhatter yellowhatter marked this pull request as ready for review April 3, 2025 06:51
@yellowhatter yellowhatter requested a review from YuanYuYuan April 3, 2025 06:52
@yellowhatter yellowhatter added the release Part of the next release label Apr 3, 2025
@yellowhatter
Copy link
Contributor Author

Finally, around 600k msgs\sec added in SHM mode (2.4 -> 3M)
This is not the final optimization, more things to be done (in another PR)

@yellowhatter yellowhatter requested review from YuanYuYuan and removed request for YuanYuYuan April 3, 2025 07:00
@yellowhatter yellowhatter removed the release Part of the next release label Apr 4, 2025
@yellowhatter yellowhatter marked this pull request as draft April 4, 2025 08:24
@yellowhatter yellowhatter marked this pull request as ready for review May 28, 2025 08:46
@yellowhatter yellowhatter added bug Something isn't working release Part of the next release labels May 28, 2025
}

impl ConfirmedSegment {
fn new(segment: Arc<MetadataSegment>, task_kick: std::sync::mpsc::Sender<()>) -> Self {
let channel_size = 65536 * 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we document why we chose two times of 64KB here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!
And thanks to your comment, I understood that I have a hidden bug with validator, I fixed that!

}

impl WatchdogValidator {
pub fn new(interval: Duration) -> Self {
let storage = Arc::new(ValidatedStorage::default());
let channel_size = 65536 * 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

And also here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@yellowhatter yellowhatter requested a review from YuanYuYuan June 9, 2025 08:04
@YuanYuYuan YuanYuYuan merged commit e6579fe into eclipse-zenoh:main Jun 10, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Existing things could work better release Part of the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants