Skip to content

Fix major problems introduced by commit 1162165 - #2489

Open
yadij wants to merge 5 commits into
squid-cache:masterfrom
yadij:arc-fd-limit-default
Open

Fix major problems introduced by commit 1162165#2489
yadij wants to merge 5 commits into
squid-cache:masterfrom
yadij:arc-fd-limit-default

Conversation

@yadij

@yadij yadij commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

... when Squid is built with select() or poll() I/O loops, and
on systems with limited resources.

... when Squid is built with select() or poll() I/O loops, and
on systems with limited resources.
Comment thread src/tools.cc Outdated
@@ -773,8 +773,8 @@ setMaxFD(void)
} else if (Config.max_filedescriptors > 0) {
#if USE_SELECT

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.

FWIW, Now that this condition is using SQUID_MAXFD_LIMIT with a sane value - we can probably drop the USE_SELECT wrapper (and modify the debugs text) - which will in turn allow removal of the checkLimits variable.

@rousskov rousskov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR description: Fix major problems introduced by commit 1162165

What major problems does this PR fix?

@kinkie kinkie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can use the type system.
The change has been build tested

Comment thread compat/compat_shared.h
Comment thread src/tools.cc Outdated
Co-authored-by: Francesco Chemolli <5175948+kinkie@users.noreply.github.com>
@yadij

yadij commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

PR description: Fix major problems introduced by commit 1162165

What major problems does this PR fix?

This PR is implementing:

// XXX: When checkLimits, take ./configure --with-filedescriptors (if any) into account.
and fixing the issues documented alongside that:

  1. // XXX: If this increases Squid_MaxFD, then the new value will violate any defined SQUID_MAXFD_LIMIT.

Squid select(2) is often enabled by ./configure as a backup I/O mechanism. As a result the Squid_MaxFD is by default almost always initialized to FD_SETSIZE - which is a relatively small value suitable for select(2) or poll(2) API structures.

  1. // XXX: The new value may make Squid_MaxFD different from SQUID_MAXFD still used by ModEpoll, ModPoll, ipcCreate(), etc.!

This is actually guaranteed to occur for at least a period during Squid startup (from

squid/src/main.cc

Lines 1433 to 1434 in dd5ea20

if (SQUID_MAXFD_LIMIT < Squid_MaxFD)
Squid_MaxFD = SQUID_MAXFD_LIMIT;
until

squid/src/main.cc

Lines 1337 to 1339 in dd5ea20

StartUsingConfig()
{
setMaxFD();
). Due to FD_SETSIZE being something smaller than the arbitrary 100*1024 constant.

@rousskov

rousskov commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

PR description: Fix major problems introduced by commit 1162165

What major problems does this PR fix?

This PR is implementing:

// XXX: When checkLimits, take ./configure --with-filedescriptors (if any) into account.

and fixing the issues documented alongside that:

  1. // XXX: If this increases Squid_MaxFD, then the new value will violate any defined SQUID_MAXFD_LIMIT.
  2. // XXX: The new value may make Squid_MaxFD different from SQUID_MAXFD still used by ModEpoll, ModPoll, ipcCreate(), etc.!

AFAICT, all of the above references point to problems that existed before commit 1162165. In other words, those problems were not "introduced by commit 1162165" as claimed in the PR title. The corresponding XXXs just documented reality that existed before that commit and continued to exist after that commit.

The discussion-relevant changes introduced by commit 1162165 can be summarized by this diff (which replaces rl.rlim_cur variable with its billion descriptors value in relevant Kubernets environments):

- Squid_MaxFD = 1073741816;
+ Squid_MaxFD =     102400;

Both values may be wrong in some cases (hence, XXXs), but the new/smaller value is certainly not worse than the old one in those problematic cases.

Even if you disagree with the above analysis, the current PR title/description does not disclose what "major problems" this PR is fixing. None of those XXXs can be easily identified as "major problems" IMO, and it is not clear that the current PR title is actually referring to those XXXs in the first place!

This PR direction was explicitly rejected during commit 1162165 (i.e. PR #2483) work as detailed in unofficial commit ce8c540 message. That fact does not imply that this direction is necessarily wrong -- different PRs have different scopes and evil comparison functions -- but I believe the original reasons for rejecting this direction are valid, and nothing in this PR convinces me that a different decision should be made now, in this PR.

I am pretty sure that, after the backlog issue is dealt with, the correct path forward starts with agreeing on what max_filedescriptors directive should represent (including the default behavior) and then adjusting code to match that agreement. I speculate that, on that path, we may "remove SQUID_MAXFD and its guessing ./configure code that leads to many inconsistencies and complications" (as was suggested in ce8c540).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants