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

ringhash: allow overriding max ringhash size via environment variable #5884

Merged
merged 4 commits into from Dec 22, 2022

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Dec 21, 2022

Implement the remaining part of grpc/proposal#338 after #5801 (allowing the maximum size to be overridden).

RELEASE NOTES:

  • xds/ringhash: introduce GRPC_RING_HASH_CAP environment variable to override the maximum ring size.


// XDSRingHashLimit indicates the maximum ring size which defaults to 4096 but
// may be overridden by setting the environment variable
// "GRPC_XDS_RING_HASH_LIMIT". A hard maximum limit of 8MB and minimum limit
Copy link
Contributor

Choose a reason for hiding this comment

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

RING_HASH_LIMIT is somewhat ambiguous, since this limit really controls the max number of ring hash entries, and only indirectly controls memory (e.g. per-entry memory consumption could be reduced with a revised layout).

Note too the A hard maximum limit of 8MB should say something like A hard maximum limit of 8 million entries, which can consume ~256MB.

Copy link
Member Author

@dfawley dfawley Dec 21, 2022

Choose a reason for hiding this comment

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

RING_HASH_LIMIT

Can you suggest something better? I wanted to avoid something too verbose. GRPC_XDS_RING_SIZE_LIMIT is probably too vague, and GRPC_XDS_RING_HASH_RING_SIZE_LIMIT is getting pretty long. Is GRPC_XDS_RING_HASH_SIZE_LIMIT still too ambiguous?

Note too the A hard maximum limit of 8MB should say something like A hard maximum limit of 8 million entries, which can consume ~256MB

Well, it's apparently not 8 million either, it's 8,388,608. Why did we choose that number (for Java) btw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh wait.. we actually NACK for configs > 8M. So probably this is irrelevant to even mention here?

Copy link
Contributor

Choose a reason for hiding this comment

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

In C++, their's a channel option called GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP.

In Java, the global is setRingSizeCap.

So maybe use GRPC_XDS_RING_HASH_CAP ?

Oh wait.. we actually NACK for configs > 8M. So probably this is irrelevant to even mention here?

Yeah I think it's not really relevant. Though I suppose we could mention that GRPC_XDS_RING_HASH_CAP does not influence the validation of max ring size configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

So maybe use GRPC_XDS_RING_HASH_CAP?

This is fine since it matches the other languages re: cap/limit, though I find "cap" to be less formal/precise than "limit".

Changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, should we remove "xds" from the name, too, since the LB policy name doesn't have "xds" in it?

Copy link
Member Author

Choose a reason for hiding this comment

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

(I went ahead and did that in another commit; LMK.)

@@ -36,4 +37,23 @@ var (
// AdvertiseCompressors is set if registered compressor should be advertised
// ("GRPC_GO_ADVERTISE_COMPRESSORS" is not "false").
AdvertiseCompressors = !strings.EqualFold(os.Getenv(advertiseCompressorsStr), "false")
// XDSRingHashCap indicates the maximum ring size which defaults to 4096
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/XDSRingHashCap/RingHashCap

Copy link
Member Author

Choose a reason for hiding this comment

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

Not just a nit; vet won't pass like this. Fixed.

Copy link
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

LGTM

want uint64
}{
{
name: "error parsing; want default",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change the test names to be in snake_case instead, as the go test command would do that anyways, and will ;s in there, the test name might look weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is fine IMO. AFAICT there's no real guidance given on this by the Go team, and the name is essentially just a convenience & informational. No matter what we name things, they will be copy-pasteable to re-run. That said, the "want"s are pretty obvious, especially given the "want" declaration, so I just removed them.

Comment on lines +64 to +65
if tc.val == "" {
os.Unsetenv(testVar)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this special case for empty string? Since the code which reads the env var uses os.GetEnv(), and does not distinguish between whether the env var is set to empty string vs being unset, can't we simply set it to the empty string here (for the appropriate test case)?

Copy link
Member Author

Choose a reason for hiding this comment

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

From a blackbox testing perspective, it's an interesting, specific test. But from a whitebox perspective, it's no different. So I could go either way, but I'm inclined to keep it with the former in mind.

@easwars easwars assigned dfawley and unassigned easwars Dec 21, 2022
@dfawley dfawley merged commit 4565dd7 into grpc:master Dec 22, 2022
1 check passed
@dfawley dfawley deleted the ringhashcap branch December 22, 2022 16:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants