Skip to content

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

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

cason merged 8 commits into
mainfrom
dev/single_sendmonitor_update

Conversation

@ValarDragon

@ValarDragon ValarDragon commented Jul 1, 2024 •

Copy link
Copy Markdown
Contributor

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

@melekes melekes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @ValarDragon ❤️

Comment thread p2p/conn/connection.go Resolved
Comment thread p2p/conn/connection.go Resolved
Comment thread p2p/conn/connection.go Resolved

@cason cason left a comment

Copy link
Copy Markdown

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.

Comment thread p2p/conn/connection.go Resolved
Comment thread p2p/conn/connection.go Resolved
@ValarDragon

Copy link
Copy Markdown
Contributor Author

Great catch, fixed!

@cason cason left a comment

Copy link
Copy Markdown

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...

Comment thread p2p/conn/connection.go Resolved
Comment thread p2p/conn/connection.go Resolved
Comment thread p2p/conn/connection.go Outdated
return true
return n, true
}
// TODO: Change this to only do one update for the entire bawtch.

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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 <[email protected]>
Co-authored-by: Daniel <[email protected]>
(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 <[email protected]>
Co-authored-by: Daniel <[email protected]>
(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 <[email protected]>
Co-authored-by: Daniel <[email protected]>
(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 <[email protected]>
@melekes

melekes commented Jul 10, 2024

Copy link
Copy Markdown
Collaborator

@mergify backport v1.x

@mergify

mergify Bot commented Jul 10, 2024 •

Copy link
Copy Markdown
Contributor

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 <[email protected]>
Co-authored-by: Daniel <[email protected]>
(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 <[email protected]>
Co-authored-by: Anton Kaliaev <[email protected]>
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