Skip to content

Optimize blacklist cache reload locking#7

Merged
vansour merged 1 commit intomainfrom
codex/identify-optimization-opportunities-in-rust-code
Oct 30, 2025
Merged

Optimize blacklist cache reload locking#7
vansour merged 1 commit intomainfrom
codex/identify-optimization-opportunities-in-rust-code

Conversation

@vansour
Copy link
Copy Markdown
Owner

@vansour vansour commented Oct 30, 2025

Summary

  • return shared Arc<Vec<String>> instances from the blacklist cache so readers reuse cached entries without cloning
  • read the cache under a shared lock and only upgrade to a write lock when the file has changed

Testing

  • cargo fmt
  • cargo check
  • cargo test
  • cargo clippy --all-targets --all-features

https://chatgpt.com/codex/tasks/task_e_69022389953483238b0d9b51eb82be7d

Copilot AI review requested due to automatic review settings October 30, 2025 01:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the blacklist loading mechanism by addressing a race condition and reducing unnecessary cloning. The changes wrap the rules vector in an Arc to enable cheap sharing and implement a double-check locking pattern to avoid holding a write lock while checking if a reload is needed.

  • Changed BlacklistCache.rules from Vec<String> to Arc<Vec<String>> for efficient sharing
  • Implemented double-check locking pattern to check file modification before acquiring write lock
  • Updated all usages to work with the new Arc<Vec<String>> type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/services/blacklist.rs
@vansour vansour merged commit 54a6cfd into main Oct 30, 2025
10 checks passed
@vansour vansour deleted the codex/identify-optimization-opportunities-in-rust-code branch October 30, 2025 02:31
vansour added a commit that referenced this pull request Dec 7, 2025
…unities-in-rust-code

Optimize blacklist cache reload locking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants