Skip to content
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

Update AddressBook field types with concurrent collections #7040

Closed
arya2 opened this issue Jun 21, 2023 · 3 comments
Closed

Update AddressBook field types with concurrent collections #7040

arya2 opened this issue Jun 21, 2023 · 3 comments
Labels
A-concurrency Area: Async code, needs extra work to make it work properly. A-network Area: Network protocol updates or fixes C-enhancement Category: This is an improvement S-needs-design Status: Needs a design decision

Comments

@arya2
Copy link
Contributor

arya2 commented Jun 21, 2023

Motivation

This may reduce the likelihood of contention when the inbound service is responding to getpeers requests.

Possible Design

  • Replace ordered_map with a SkipMap from crossbeam-skiplist.
  • Replace most_recent_by_ip HashMap with a DashMap.
  • Use an immutable reference in update() method and take AddressBook out of the Mutex.
@arya2 arya2 added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jun 21, 2023
@mpguerra mpguerra added this to Zebra Jun 21, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in Zebra Jun 21, 2023
@arya2 arya2 added A-network Area: Network protocol updates or fixes A-concurrency Area: Async code, needs extra work to make it work properly. labels Jun 21, 2023
@arya2 arya2 added P-Low ❄️ and removed S-needs-triage Status: A bug report needs triage labels Jun 21, 2023
@teor2345 teor2345 added S-needs-design Status: Needs a design decision S-needs-triage Status: A bug report needs triage labels Jun 21, 2023
@teor2345
Copy link
Contributor

teor2345 commented Jun 21, 2023

by_addr and most_recent_by_ip have to stay consistent with each other. Currently we enforce that constraint by only allowing one thread to modify the address book at the same time.

I think this ticket needs a design that will ensure consistency during concurrent modification. This is a tricky problem to solve, which requires specialised testing. So in general we've used existing concurrency primitives in Zebra, rather than implementing our own.

So I'd suggest opening a ticket for the goal, and any evidence that will help us prioritise it. Then we can add this change as one of the alternatives.

For example, some alternatives are:

  • replacing the Mutex with a RwLock
  • replacing the thread-based concurrency primitives with async concurrency primitives, and changing all the tasks that use the address book into async tasks
  • Turn the CandidateSet and AddressBook into tower Services #1976
  • do nothing, because this issue does not have a significant impact

@arya2 arya2 removed the P-Low ❄️ label Jul 4, 2023
@arya2
Copy link
Contributor Author

arya2 commented Jul 4, 2023

So I'd suggest opening a ticket for the goal, and any evidence that will help us prioritise it.

It would solve an issue that's introduced in the current form of #7041.

I'll take a different approach in that PR, and re-open this if I see an indication in tokio-console that it's blocking the async executor.

@arya2 arya2 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2023
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Zebra Jul 4, 2023
@teor2345
Copy link
Contributor

teor2345 commented Jul 4, 2023

So I'd suggest opening a ticket for the goal, and any evidence that will help us prioritise it.

It would solve an issue that's introduced in the current form of #7041.

Thanks, I think that's a useful motivation, feel free to re-open this ticket if it's needed.

@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Async code, needs extra work to make it work properly. A-network Area: Network protocol updates or fixes C-enhancement Category: This is an improvement S-needs-design Status: Needs a design decision
Projects
Status: Done
Development

No branches or pull requests

3 participants