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

Move profile collection logic under shutdown #991

Open
radeksimko opened this issue Jul 6, 2022 · 0 comments
Open

Move profile collection logic under shutdown #991

radeksimko opened this issue Jul 6, 2022 · 0 comments
Labels
enhancement New feature or request performance Gotta go fast

Comments

@radeksimko
Copy link
Member

radeksimko commented Jul 6, 2022

Background

Whenever users report memory usage related issues, we always advise them to collect a memory profile.

Currently we collect the profiles upon cancellation (typically triggered by exit RPC notification and/or SIGINT).

if c.cpuProfile != "" {
stop, err := writeCpuProfileInto(c.cpuProfile)
defer stop()
if err != nil {
c.Ui.Error(err.Error())
return 1
}
}
if c.memProfile != "" {
defer writeMemoryProfileInto(c.memProfile)
}

While many users were able to obtain profiles that way, we discovered this strategy has two problems:

ctx, cancelFunc := lsctx.WithSignalCancel(context.Background(), logger,
os.Interrupt, syscall.SIGTERM)
defer cancelFunc()

Proposal

Move profile file to the shutdown handler

func Shutdown(ctx context.Context, _ interface{}) error {
return nil
}

@radeksimko radeksimko added the enhancement New feature or request label Jul 6, 2022
@xiehan xiehan added the performance Gotta go fast label Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Gotta go fast
Projects
None yet
Development

No branches or pull requests

2 participants