Skip to content

cosim: Remove unnecessary allocations and copying in cosim-plugin#816

Merged
Giftzwerg02 merged 4 commits intomasterfrom
feature/cosim-optimization
Mar 24, 2026
Merged

cosim: Remove unnecessary allocations and copying in cosim-plugin#816
Giftzwerg02 merged 4 commits intomasterfrom
feature/cosim-optimization

Conversation

@Giftzwerg02
Copy link
Copy Markdown
Contributor

My intuition was that letting a QEMU-client collect all the data and then just copy into the ringbuffer when done (asking for a mutex-lock only for copying) would be better than getting the mutex lock first and writing directly into the ringbuffer.

That was just wrong, a) because copying seems to take a considerable amount of time and b) because the mutex is only required when checking/waiting if the buffer is writable.

Removing this indirection using a simple refactor gains roughly 2-3x performance for the cosim!

@github-actions github-actions Bot added the enhancement New feature or request label Mar 15, 2026
@Giftzwerg02 Giftzwerg02 requested a review from Jozott00 March 15, 2026 17:11
Copy link
Copy Markdown
Contributor

@Jozott00 Jozott00 left a comment

Choose a reason for hiding this comment

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

Nice! This reminds me of the ringbuffer synchronization in the OS lecture ^^

Comment thread vadl-cosim/cosim-lib/src/ipc/cstructs.rs Outdated
@Giftzwerg02 Giftzwerg02 force-pushed the feature/cosim-optimization branch from f0652e9 to 96b77f1 Compare March 16, 2026 09:13
@Giftzwerg02 Giftzwerg02 enabled auto-merge March 16, 2026 09:14
@Giftzwerg02 Giftzwerg02 requested a review from Jozott00 March 16, 2026 09:14
@Giftzwerg02 Giftzwerg02 force-pushed the feature/cosim-optimization branch 3 times, most recently from eff0f3a to 9eae6e8 Compare March 23, 2026 01:06
@Giftzwerg02 Giftzwerg02 force-pushed the feature/cosim-optimization branch from 9eae6e8 to a2377a9 Compare March 24, 2026 15:04
@Giftzwerg02 Giftzwerg02 merged commit 732888d into master Mar 24, 2026
7 checks passed
@Giftzwerg02 Giftzwerg02 deleted the feature/cosim-optimization branch March 24, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants