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

Remove signal handling channels correctly #204

Merged
merged 2 commits into from
Mar 2, 2020

Conversation

kzys
Copy link
Contributor

@kzys kzys commented Feb 27, 2020

Issue #, if available:

#198

Description of changes:

The first commit is a benchmark to reproduce the issue. The second commit is actually fixing the issue. We are not removing signal handling channels (sigchan in setupSignals).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Since the cause is a process-level resource leak, running these
benchmarks in a same process
(e.g. go test -bench=BenchmarkForwardSignals) doesn't show
the difference.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
The "break" here only break out from the inner select statement.
The for loop is keep running and signal.Stop() won't be called.

Seems that is the cause of firecracker-microvm#198.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
Copy link
Contributor

@xibz xibz left a comment

Choose a reason for hiding this comment

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

Can we paste some benchmarks with the old vs fixed changes? Otherwise this looks good

@kzys
Copy link
Contributor Author

kzys commented Feb 28, 2020

Sure. Before the change (c3bc513):

% sudo DISABLE_ROOT_TESTS= ~/src/go1.14/bin/go test -run=XXX -bench=BenchmarkForwardSignalsDefault -benchtime=1x
goos: linux
goarch: amd64
pkg: github.com/firecracker-microvm/firecracker-go-sdk
BenchmarkForwardSignalsDefault-96              1        3856837117 ns/op
--- BENCH: BenchmarkForwardSignalsDefault-96
    benchmark_test.go:106: BenchmarkForwardSignalsDefault: 1
    benchmark_test.go:106: BenchmarkForwardSignalsDefault: 1
PASS
ok      github.com/firecracker-microvm/firecracker-go-sdk       24.299s
% sudo DISABLE_ROOT_TESTS= ~/src/go1.14/bin/go test -run=XXX -bench=BenchmarkForwardSignalsDisable -benchtime=1x
goos: linux
goarch: amd64
pkg: github.com/firecracker-microvm/firecracker-go-sdk
BenchmarkForwardSignalsDisable-96              1         558669169 ns/op
--- BENCH: BenchmarkForwardSignalsDisable-96
    benchmark_test.go:106: BenchmarkForwardSignalsDisable: 1
    benchmark_test.go:106: BenchmarkForwardSignalsDisable: 1
PASS
ok      github.com/firecracker-microvm/firecracker-go-sdk       1.311s

After the change (f8cf437):

% sudo DISABLE_ROOT_TESTS= ~/src/go1.14/bin/go test -run=XXX -bench=BenchmarkForwardSignalsDefault -benchtime=1x
goos: linux
goarch: amd64
pkg: github.com/firecracker-microvm/firecracker-go-sdk
BenchmarkForwardSignalsDefault-96              1         566526518 ns/op
--- BENCH: BenchmarkForwardSignalsDefault-96
    benchmark_test.go:106: BenchmarkForwardSignalsDefault: 1
    benchmark_test.go:106: BenchmarkForwardSignalsDefault: 1
PASS
ok      github.com/firecracker-microvm/firecracker-go-sdk       1.328s
% sudo DISABLE_ROOT_TESTS= ~/src/go1.14/bin/go test -run=XXX -bench=BenchmarkForwardSignalsDisable -benchtime=1x
goos: linux
goarch: amd64
pkg: github.com/firecracker-microvm/firecracker-go-sdk
BenchmarkForwardSignalsDisable-96              1         548990953 ns/op
--- BENCH: BenchmarkForwardSignalsDisable-96
    benchmark_test.go:106: BenchmarkForwardSignalsDisable: 1
    benchmark_test.go:106: BenchmarkForwardSignalsDisable: 1
PASS
ok      github.com/firecracker-microvm/firecracker-go-sdk       1.257s

Copy link
Contributor

@mxpv mxpv left a comment

Choose a reason for hiding this comment

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

LGTM

@kzys kzys merged commit 5f3b54f into firecracker-microvm:master Mar 2, 2020
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.

None yet

3 participants