Skip to content

fix(shared-state): replace O(n) DirtyVec eviction with VecDeque#82

Open
SH20RAJ wants to merge 1 commit intomofa-org:mainfrom
SH20RAJ:fix/23-dirtyvec-vecdeque
Open

fix(shared-state): replace O(n) DirtyVec eviction with VecDeque#82
SH20RAJ wants to merge 1 commit intomofa-org:mainfrom
SH20RAJ:fix/23-dirtyvec-vecdeque

Conversation

@SH20RAJ
Copy link
Copy Markdown

@SH20RAJ SH20RAJ commented Apr 1, 2026

Summary

  • fix DirtyVec::push performance regression when buffer is full
  • replace Vec + remove(0) with VecDeque + pop_front() for O(1) eviction
  • keep external API unchanged (read_if_dirty / read_all still return Vec<T>)

Why

When DirtyVec reaches max size, each push previously shifted all elements (remove(0)), creating O(n) behavior under high update rates.

Issue

Fixes #23

Validation

I could not run cargo test in this environment because cargo is unavailable in PATH; this change is narrowly scoped to one container type and preserves all public method signatures.

@SH20RAJ
Copy link
Copy Markdown
Author

SH20RAJ commented Apr 1, 2026

Quick follow-up: this fix replaces DirtyVec front removal with VecDeque O(1) eviction and keeps read_if_dirty/read_all APIs unchanged. If you want, I can add micro-benchmark output in a follow-up comment once local cargo bench is run in CI-ready env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: O(n) performance issue in DirtyVec::push due to Vec::remove(0)

1 participant