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

optimize process-user-data startup time #2160

Conversation

mkulke
Copy link
Collaborator

@mkulke mkulke commented Nov 19, 2024

the binary is currently importing a lot of libraries which have costly init() procedures (around 8-10s at startup) this is due to sharing some consts with the CAA modules. We can avoid that by inlining code in process-user-data and moving shared consts into dedicated modules.

We can use a cpuid field to narrow down a hypervisor, so we don't have to probe an IMDS endpoint while circling through the cloud provider, delaying startup.

this is the result w/ debug enabled, the crypto libraries that are used to hash initdata are still consuming a few, but it's far better now.

Nov 19 15:51:19 fedora process-user-data[676]: init main @1029 ms, 0.039 ms clock, 2600 bytes, 22 allocs

@mkulke mkulke changed the title Mkulke/optimize process user data startup mkulke/optimize process user data startup Nov 19, 2024
@mkulke mkulke changed the title mkulke/optimize process user data startup optimize process user data startup Nov 19, 2024
@mkulke mkulke force-pushed the mkulke/optimize-process-user-data-startup branch 6 times, most recently from 65149b6 to 46be024 Compare November 19, 2024 16:44
@mkulke mkulke changed the title optimize process user data startup optimize process-user-data startup time Nov 19, 2024
@mkulke mkulke marked this pull request as ready for review November 19, 2024 16:44
@mkulke mkulke requested a review from a team as a code owner November 19, 2024 16:44
@mkulke mkulke added the test_e2e_libvirt Run Libvirt e2e tests label Nov 19, 2024
@mkulke mkulke force-pushed the mkulke/optimize-process-user-data-startup branch 2 times, most recently from 8253fc8 to d889a65 Compare November 21, 2024 09:39
@mkulke mkulke force-pushed the mkulke/optimize-process-user-data-startup branch from d889a65 to 4469e2a Compare November 21, 2024 09:42
Copy link
Member

@stevenhorsman stevenhorsman left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the updates!

logger.Printf("provider: AWS, userDataUrl: %s\n", url)
return aws.GetUserData(ctx, url)
return imdsGet(ctx, url, false, nil)
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the bool be true here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aws doesn't encode the userdata with base64, does it? at least it wasn't in the original code

Copy link
Member

Choose a reason for hiding this comment

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

Correct.. I forgot about it.. Do you mind adding a comment above the code ?

Copy link
Member

@bpradipt bpradipt left a comment

Choose a reason for hiding this comment

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

/lgtm

the binary is currently importing a lot of libraries which have costly
init() procedures (around 8-10s at startup) this is due to sharing
some consts with the CAA modules. We can avoid that by inlining code
in process-user-data and moving shared consts into dedicated modules.

We can use a cpuid field to narrow down a hypervisor, so we don't have
to probe an IMDS endpoint while circling through the cloud provider,
delaying startup.

Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
@mkulke mkulke force-pushed the mkulke/optimize-process-user-data-startup branch from 4469e2a to 0b5f9f4 Compare November 21, 2024 11:33
@mkulke mkulke merged commit 037c4b5 into confidential-containers:main Nov 21, 2024
19 of 21 checks passed
@mkulke mkulke deleted the mkulke/optimize-process-user-data-startup branch November 21, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_e2e_libvirt Run Libvirt e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants