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

ERL: Use IP address instead of IP:port pair #6176

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Nov 20, 2024

Summary

Make ERL more strict by distinguishing IP addresses instead of connections.
Idea (basically as suggested in this comment: #6176 (comment))

  1. TxHandler how has erlClientMapper entity that maps sender's addresses to a meta peer erlIPClient.
  2. ERL gets the same erlIPClient for senders (connections) with the same address and it's logic not changed.
  3. erlIPClient tracks senders with the same address.
  4. erlIPClient sets own OnClose handlers so that when network actually closes a connection, this handler is called.
  5. When all connections closed (peers removed) the main OnClose called to notify ERL about this client termination.

Test Plan

  • A new erlIPClient unit test
  • ERL-counting/correctness test
  • Cluster performance test results
branch results
master relay summary: 8263.21 TPS, 3.12s/block, tx 56.4MB/s, rx 36.4MB/s, p2p tx 0.00B/s, p2p rx 0.00B/s
feature relay summary: 8316.12 TPS, 3.10s/block, tx 52.4MB/s, rx 33.8MB/s, p2p tx 0.00B/s, p2p rx 0.00B/s

Memory use remained the same but the test does not have thousands of clients to tell for sure.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.80%. Comparing base (8fce49c) to head (33ae225).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6176      +/-   ##
==========================================
+ Coverage   51.79%   51.80%   +0.01%     
==========================================
  Files         644      644              
  Lines       86511    86546      +35     
==========================================
+ Hits        44805    44836      +31     
- Misses      38834    38840       +6     
+ Partials     2872     2870       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@algorandskiy algorandskiy requested review from cce and gmalouf November 20, 2024 13:47
util/rateLimit.go Outdated Show resolved Hide resolved
@algorandskiy algorandskiy marked this pull request as draft November 21, 2024 00:21
var capguard *util.ErlCapacityGuard
var isCMEnabled bool
var err error
if handler.erl != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved the handler.erl != nil check to processIncomingTxn

@algorandskiy algorandskiy requested a review from cce February 16, 2025 21:11
@algorandskiy algorandskiy marked this pull request as ready for review February 16, 2025 21:12
Comment on lines +696 to +706
eic.m.Unlock()
// if no elements left, call the closer
// use atomic Swap in order to retrieve the closer and call it once
if empty {
// atomic.Value.Swap does not like nil values so use a typed nil
// and cast it to func() in order to compare with nil
if closer := eic.closer.Swap((func())(nil)).(func()); closer != nil {
closer()
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use both a mutex and an atomic? Could you protect the eic.clients and the eic.closer with the eic.m mutex, so you don't have to do the special handling/casting of the atomic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to reduce the mutex congestion: the close function could be relatively expensive and require own locks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants