Skip to content

Switch read-heavy Mutex fields to RwLock for concurrent reads#95

Open
an0nn30 wants to merge 1 commit intomainfrom
perf/rwlock-read-heavy-state
Open

Switch read-heavy Mutex fields to RwLock for concurrent reads#95
an0nn30 wants to merge 1 commit intomainfrom
perf/rwlock-read-heavy-state

Conversation

@an0nn30
Copy link
Copy Markdown
Owner

@an0nn30 an0nn30 commented Mar 28, 2026

What does this PR do?

Replaces parking_lot::Mutex with parking_lot::RwLock for three read-heavy shared state fields:

Field Read:Write Ratio Readers
TauriState.config ~100:1 Every command reads config; only settings save writes
PluginState.panels ~50:1 Panel queries frequent; registration rare
PluginState.menu_items ~50:1 Menu rebuilds frequent; plugin register rare

36 call sites updated across 6 files. Read-only access uses .read(), mutations use .write().

Type of change

  • Performance improvement

Testing

  • Builds without errors
  • All 119 conch_tauri tests pass
  • No regressions — pure performance refactor

Replace parking_lot::Mutex with RwLock on TauriState.config,
PluginState.panels, and PluginState.menu_items. These fields are
read on nearly every Tauri command but written only on settings
save or plugin enable/disable. RwLock allows concurrent readers
while still providing exclusive write access when needed.

- TauriState.config: .read() for all query commands, .write() only
  in save_settings
- PluginState.panels: .read() for get_plugin_panels/get_panel_widgets,
  .write() for register_panel/set_widgets/cleanup
- PluginState.menu_items: .read() for get_plugin_menu_items/menu rebuild,
  .write() for register_menu_item/cleanup
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.

1 participant