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

Disable Transparent Hugepage #4174

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

Conversation

cartoush
Copy link
Contributor

No description provided.

@nigoroll
Copy link
Member

nigoroll commented Sep 12, 2024

🤔
I am aware of the problem, but is this not a specific jemalloc+THP issue which surfaces exclusively with the malloc storage? For cases where the malloc storage is not used, disabling THP might be counter-productive (after all, there is a good reason for introducing it to reduce TLB misses), so if this was otherwise found to be a useful addition, I would ask to at least make it a jail flag, possibly on by default, but possible to disable.

(oh, and also, are these really "stability" issues? All I am aware of is memory usage going overboard)

@nigoroll
Copy link
Member

I cherry-picked the first commit to master because it improves documentation for the release.

@cartoush cartoush force-pushed the disable_thp branch 2 times, most recently from 22a3a4f to d4e100b Compare September 12, 2024 16:29
@dridi
Copy link
Member

dridi commented Sep 13, 2024

Varnish used to crash left and right when Transparent Hugepage first landed, and we sometime still see inexplicable problems go away once we disable the feature.

I'm fine with the addition of a jail option to control this, would you agree to disabled by default?

@bsdphk
Copy link
Contributor

bsdphk commented Sep 16, 2024

As a matter of principle, I'll be +0 on how linux_jail works and what it does.

@nigoroll
Copy link
Member

bugwash: @cartoush please make this a jail option. disabled by default is preferred, enabled by default would also work for me, as long as there is admin control at all

Copy link
Member

@dridi dridi left a comment

Choose a reason for hiding this comment

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

LGTM modulus a few nit picks.

bin/varnishd/mgt/mgt_jail_linux.c Outdated Show resolved Hide resolved
doc/sphinx/reference/varnishd.rst Outdated Show resolved Hide resolved
@cartoush cartoush force-pushed the disable_thp branch 3 times, most recently from 0677fd9 to c6d0f08 Compare September 20, 2024 15:14
Copy link
Member

@dridi dridi left a comment

Choose a reason for hiding this comment

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

At this point, I'm only left with docs nitpicks.

bin/varnishd/mgt/mgt_jail_linux.c Outdated Show resolved Hide resolved
doc/sphinx/reference/varnishd.rst Outdated Show resolved Hide resolved
doc/sphinx/reference/varnishd.rst Outdated Show resolved Hide resolved
Copy link
Member

@nigoroll nigoroll left a comment

Choose a reason for hiding this comment

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

I only have nitpicks, too

AN(unix_args);

for (i = 0; *args != NULL && ret == 0; args++) {
if (!strncmp(*args, "transparent_hugepage=", 21)) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we please at least replace the magic 21 with something like

	const char const *thpa = "transparent_hugepage=";
	const size_t l = strlen(thpa);

Copy link
Member

Choose a reason for hiding this comment

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

FYI this was drawing inspiration from the UNIX jail.

Copy link
Member

Choose a reason for hiding this comment

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

4001ea2
FTR, in the example above I got one const wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe sizeof("transparent_hugepage=") - 1 would be appropriate and avoid calling strlen just for that ?

Copy link
Member

Choose a reason for hiding this comment

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

Or sizeof("transparent_hugepage") to swallow the equal sign :p

A call to strlen() for a static string will likely be optimized out at compile time, but if anything I'd rather work with a macro here and in the UNIX jail:

if ((val = ARG_MATCH(*args, transparent_hugepage)) != NULL)
        ret = vjl_set_thp(val);

Less ceremony, and the macro is in charge of dealing with the equal sign and value offset.

Copy link
Member

Choose a reason for hiding this comment

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

That was fast, but I only meant to make a suggestion here. I'm interested in @nigoroll's opinion on my suggestion, which would do more than the macro you pushed.

Copy link
Member

Choose a reason for hiding this comment

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

maybe sizeof("transparent_hugepage=") - 1 would be appropriate and avoid calling strlen just for that ?

see 4001ea2: This is constant, so strlen is no more expensive than sizeof and happens at compile or init time. Plus it's irrelevant, because the code runs exactly once.

Copy link
Member

Choose a reason for hiding this comment

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

@dridi

I'd rather work with a macro here and in the UNIX jail:

can you show how the macro would look like in vju_init? I thought about it but could not see a nice way cause of the "error if vju_get* fails, else continue"

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I remove my 2nd commit and let this be decided in #4202 ?

doc/sphinx/installation/platformnotes.rst Outdated Show resolved Hide resolved
nigoroll added a commit that referenced this pull request Sep 23, 2024
cartoush added a commit to cartoush/varnish-cache that referenced this pull request Sep 25, 2024
This commit provides a more elegant way to check
jail arguments.
It was motivated by this comment varnishcache#4174 (comment)
Disabling Transparent Hugepage has often been the solution to solve
hard-to-diagnose instability issues and despite improvements in this
area compared to the RHEL6 era, our recommandation is still to avoid
THP to this day.

In addition to refreshing the documentation on this topic, the Linux
jail will tentatively disable THP or warn when it cannot.
This commit provides a more elegant way to check
jail arguments.
It was motivated by this comment varnishcache#4174 (comment)
dridi added a commit to dridi/varnish-cache that referenced this pull request Sep 26, 2024
TODO: find a name and a home for the ARG_MATCH() macro.

Refs 4001ea2
Refs varnishcache#4174
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.

5 participants