Skip to content

perf(p2p): Only update send monitor once per batch packet msg send#3382

Merged
cason merged 8 commits intomainfrom
dev/single_sendmonitor_update
Jul 3, 2024
Merged

perf(p2p): Only update send monitor once per batch packet msg send#3382
cason merged 8 commits intomainfrom
dev/single_sendmonitor_update

Conversation

@ValarDragon
Copy link
Contributor

@ValarDragon ValarDragon commented Jul 1, 2024

Small optimization to outbound packet gossip, I expect this to be a 1-2% speedup to outbound packet gossip as is right now. Will test on mainnet soon

This is safe as outbound packet gossip is single threaded per peer as is right now. Technically makes the send monitor marginally less real time, but this is irrelevant as the send monitor works on 20ms sliding windows anyway


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

@ValarDragon ValarDragon requested a review from a team as a code owner July 1, 2024 11:23
@ValarDragon ValarDragon requested a review from a team July 1, 2024 11:23
@ValarDragon ValarDragon changed the title Only update send monitor once per batch packet msg send perf(p2p): Only update send monitor once per batch packet msg send Jul 1, 2024
Copy link
Collaborator

@melekes melekes left a comment

Choose a reason for hiding this comment

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

Thanks @ValarDragon ❤️

Copy link

@cason cason left a comment

Choose a reason for hiding this comment

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

Good. By I wondering if we are preserving the same behavior as before, in particular in terms of the error handling.

In short, if we return at line 533 we are not updating the monitor at all, even with the bytes sent in previously and successful calls. The same is valid for line 529, isn't it?

The solution I suggest is to update the sendMonitor as part of a defer clause, it is done in any case.

ValarDragon and others added 2 commits July 1, 2024 21:24
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
@ValarDragon
Copy link
Contributor Author

Great catch, fixed!

Copy link

@cason cason left a comment

Choose a reason for hiding this comment

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

Good.

There is a mandatory fix, line 542 to be removed, otherwise the behavior will be wrong.

I think we would need to have some test units for this rate limiting implementation...

return true
return n, true
}
// TODO: Change this to only do one update for the entire bawtch.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// TODO: Change this to only do one update for the entire bawtch.

Copy link

Choose a reason for hiding this comment

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

TODO solved, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This still applies for the flush monitor

@cason cason enabled auto-merge July 3, 2024 07:12
@cason cason added this pull request to the merge queue Jul 3, 2024
Merged via the queue into main with commit 20d8630 Jul 3, 2024
@cason cason deleted the dev/single_sendmonitor_update branch July 3, 2024 10:21
@ValarDragon ValarDragon added the backport-to-v0.38.x Tell Mergify to backport the PR to v0.38.x label Jul 3, 2024
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
…3382)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

#### PR checklist

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: Daniel <daniel.cason@informal.systems>
(cherry picked from commit 20d8630)

# Conflicts:
#	.changelog/v0.38.8/improvements/3382-single-send-monitor-per-packet.md
ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Jul 3, 2024
…ometbft#3382)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: Daniel <daniel.cason@informal.systems>
(cherry picked from commit 20d8630)
itsdevbear pushed a commit to berachain/cometbft that referenced this pull request Jul 4, 2024
…ometbft#3382)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: Daniel <daniel.cason@informal.systems>
(cherry picked from commit 20d8630)
melekes pushed a commit that referenced this pull request Jul 5, 2024
…ackport #3382) (#3417)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

#### PR checklist

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3382 done by
[Mergify](https://mergify.com).

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
@melekes
Copy link
Collaborator

melekes commented Jul 10, 2024

@mergify backport v1.x

@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2024

backport v1.x

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Jul 10, 2024
…3382)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

#### PR checklist

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: Daniel <daniel.cason@informal.systems>
(cherry picked from commit 20d8630)
melekes added a commit that referenced this pull request Jul 10, 2024
…ackport #3382) (#3487)

Small optimization to outbound packet gossip, I expect this to be a 1-2%
speedup to outbound packet gossip as is right now. Will test on mainnet
soon

This is safe as outbound packet gossip is single threaded per peer as is
right now. Technically makes the send monitor marginally less real time,
but this is irrelevant as the send monitor works on 20ms sliding windows
anyway

---

#### PR checklist

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3382 done by
[Mergify](https://mergify.com).

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v0.38.x Tell Mergify to backport the PR to v0.38.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants