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

Use WSD-config or system's maximum concurrent TCP connections for net::Defaults.maxTCPConnections #10375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgothel
Copy link

@sgothel sgothel commented Oct 30, 2024

Summary

net::Defaults.maxTCPConnections: Use WSD-config or system's maximum concurrent TCP connections

net::Defaults.maxExtConnections is set:

  • use COOLWSD config net.max_ext_connections if >= COOLWSD::MinConnectedSessions
  • or is disabled (zeroed) if config < 0.
  • otherwise set to system-value, see Util::getMaxConcurrentTCPConnections.

Util::getMaxConcurrentTCPConnections uses Linux kernel values

The Linux kernel values are memory bound, approximately 4 concurrent TCP connections per MB system memory are provided,
e.g. {4096M -> 16384}, {16384M -> 65536}, {65407M -> 262144}, ...

COOLWSD::MinConnectedSessions is a static constexpr with value 3, symbolized for clarity.

Checklist

  • I have run make prettier-write and formatted the code.
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

@sgothel sgothel added the 24.04 label Oct 30, 2024
@sgothel sgothel self-assigned this Oct 30, 2024
@sgothel sgothel requested a review from caolanm October 30, 2024 11:49
@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch 7 times, most recently from 68933f6 to 92d8955 Compare November 1, 2024 10:39
@sgothel
Copy link
Author

sgothel commented Nov 1, 2024

desktop cypress calc/searchbar_spec.js post rebase on a2f3536, while PR #10370 passed. Hence it got better .. but not fully resolved yet.

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from 92d8955 to 7597fb3 Compare November 1, 2024 12:30
@caolanm
Copy link
Contributor

caolanm commented Nov 1, 2024

I feel readDecimal and dataToDecimal are a bit ornate if we compare to say getTotalSystemMemoryKb or getFromCGroup which just open their /proc file, read a line from it and atoll on that

@sgothel
Copy link
Author

sgothel commented Nov 1, 2024

I feel readDecimal and dataToDecimal are a bit ornate if we compare to say getTotalSystemMemoryKb or getFromCGroup which just open their /proc file, read a line from it and atoll on that

looked at them ofc and thought about adding this func .. esp due to late reviews :)
problem, the used atoll (edit: existing code) is not covering all error cases and I wanted a one liner to fetch the value
to have the getTechValue func clean of these things - encapsulation.
If its a blocker, I will revise.

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from 7597fb3 to 342435e Compare November 1, 2024 14:20
@sgothel
Copy link
Author

sgothel commented Nov 1, 2024

added a tiny fix on calling readDecimal (EOS included), refined its API doc .. kicking CI again (ole cypress failure)

Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

Some good things here that can go in - but a number that need feedback. I -really- don't want review getting lost and ignored in monster review threads of giant collections of commits. It is good to split them up - lets also push them in small batches to different PRs.

checkRemoval -> fine.

Simplify UnitTimeoutBase -> no idea - a huge change with no clear rationale.

Add 'UT' -> the 'UT' is not needed - lets not make up lots of new acronyms in commit messages it is implicit in UnitTestFoo - otherwise good to see a new test -> fine.

is "Remove WebSocketHandler's WS Ping timeout functionality" a nearly straight revert - if so good; lets include the word 'Revert' in the commit message - otherwise fine.

Like the Remove redundant 'Socket::isClosed()' - but I would prefer us to remove 'isOpen' to minimize the end-to-end diff across the code. We don't want non-functional renames of methods isClosed -> isOpen is not a win.

"Add safe ..." don't like creating big, redundant helpers like this. We already have similar code, using other helpers that does this - git grep for & re-use the same code there.

why tcp_max_orphans ?

Thanks!

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch 3 times, most recently from a3b53eb to dd4b6ae Compare November 6, 2024 15:11
@sgothel
Copy link
Author

sgothel commented Nov 6, 2024

Simplify UnitTimeoutBase -> no idea - a huge change with no clear rationale.

Not huge IMHO, but simplifying the unit test more to its point, which pattern is also more reusable for other users.

Add 'UT' -> the 'UT' is not needed - lets not make up lots of new acronyms in commit messages it is implicit in UnitTestFoo - otherwise good to see a new test -> fine.

Fun fact, I read this abbreviation somewhere else .. and picked it up. OK.

Like the Remove redundant 'Socket::isClosed()' - but I would prefer us to remove 'isOpen' to minimize the end-to-end diff across the code. We don't want non-functional renames of methods isClosed -> isOpen is not a win.

I counted usage of both, and isOpen was used more often without inversion
while isClosed required inversion - so this is more straight, a win.

"Add safe ..." don't like creating big, redundant helpers like this. We already have similar code, using other helpers that does this - git grep for & re-use the same code there.

std::stroll used here covers all error cases, while existing code does not (using atoll).
Initial motivation to factor it out of the actual evaluation function was to not
have it littered with ordinary and distracting I/O and conversion details.

(other items were either accepted or discussed in upcoming PRs)

Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

When feedback is incorporated systematically please poke me to review again. Thanks.

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch 4 times, most recently from 88b0d10 to 2764bcd Compare November 8, 2024 13:23
@sgothel sgothel changed the title Revise Handle Limited Open Connections (2) Use system's maximum concurrent TCP connections for net::Defaults.maxTCPConnections Nov 8, 2024
@sgothel
Copy link
Author

sgothel commented Nov 11, 2024

When feedback is incorporated systematically please poke me to review again. Thanks.

Done.

Remark: The requested removal of Socket::isOpen() instead of Socket::isClose() increased the diff as laid out earlier. Regardless, I hope it fits requirements as I also changed the field name to have the accessor match 1:1 w/o inverted logic.

Other changes applied as requested as well.

@sgothel sgothel requested a review from mmeeks November 11, 2024 15:23
@caolanm caolanm force-pushed the private/sgothel/socketcode_repair_3 branch from 2764bcd to e97b802 Compare November 11, 2024 19:26
common/Util-desktop.cpp Fixed Show resolved Hide resolved
@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from e97b802 to d95881e Compare November 11, 2024 23:03
@sgothel
Copy link
Author

sgothel commented Nov 11, 2024

Cleaned up branch rebased tree, i.e. PR #10375 -> #10455 -> #10456

(also refined getMaxConcurrentTCPConnections less nonsense analytics scaring comparison and borderline unsigned long long > numeric_limits<size_t>::max() check)

Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

Lets get the first two commits in- but not the third - which needs re-working.

common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-mobile.cpp Outdated Show resolved Hide resolved
net/Socket.cpp Outdated Show resolved Hide resolved
wsd/COOLWSD.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from d95881e to 0175d07 Compare November 13, 2024 13:42
Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

Some more work to do - as well as splitting from the underlying un-necessary extra commit.

common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
common/Util-desktop.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

Minor changes but lets get them done first.

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from 0175d07 to ee52b02 Compare November 20, 2024 09:11
@sgothel
Copy link
Author

sgothel commented Nov 20, 2024

force push: rebase to master only

@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from ee52b02 to f22b4cc Compare November 20, 2024 12:10
@sgothel
Copy link
Author

sgothel commented Nov 20, 2024

Addressed comments, added config value etc.

@sgothel sgothel changed the title Use system's maximum concurrent TCP connections for net::Defaults.maxTCPConnections Use WSD-config or system's maximum concurrent TCP connections for net::Defaults.maxTCPConnections Nov 20, 2024
Copy link
Contributor

@Ashod Ashod left a comment

Choose a reason for hiding this comment

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

Thanks, @sgothel. Left some comments/notes.

test/UnitTimeoutNone.cpp Show resolved Hide resolved
common/Util-server.cpp Outdated Show resolved Hide resolved
…oncurrent TCP connections

`net::Defaults.maxExtConnections` is set:
- use COOLWSD config `net.max_ext_connections` if >= `COOLWSD::MinConnectedSessions`
- or is disabled (zeroed) if config < 0.
- otherwise set to system-value, see `Util::getMaxConcurrentTCPConnections`.

`Util::getMaxConcurrentTCPConnections` uses Linux kernel values
- /proc/sys/net/ipv4/tcp_max_orphans
  See https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html
- /proc/sys/net/nf_conntrack_max
  See https://www.kernel.org/doc/html/latest/networking/nf_conntrack-sysctl.html
- or returns zero if undefined

The Linux kernel values are memory bound, approximately 4 concurrent TCP connections per MB system memory are provided,
e.g. {4096M -> 16384}, {16384M -> 65536}, {65407M -> 262144}, ...

`COOLWSD::MinConnectedSessions` is a static constexpr with value 3, symbolized for clarity.

Signed-off-by: Sven Göthel <[email protected]>
Change-Id: Iad74f253bdac5636757b130b299b5deacda658db
@sgothel sgothel force-pushed the private/sgothel/socketcode_repair_3 branch from f22b4cc to 36915ef Compare November 21, 2024 11:54
@sgothel
Copy link
Author

sgothel commented Nov 21, 2024

push:

  • Using Util::u64FromString
  • Refined comment hinting on tri-state of WSD config net.max_ext_connections as described in net::DefaultValues::maxExtConnections

@sgothel sgothel requested a review from mmeeks November 22, 2024 09:27
@mmeeks mmeeks assigned Ashod and unassigned sgothel Dec 12, 2024
@mmeeks
Copy link
Contributor

mmeeks commented Dec 12, 2024

@Ashod - can you do some thinking on whether we want this, and get it in if so ? =)

@Ashod
Copy link
Contributor

Ashod commented Dec 28, 2024

@Ashod - can you do some thinking on whether we want this, and get it in if so ? =)

Yes, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Handle limited open Connections due to keepalive connections (cool#9621)
4 participants