commit | ea91d68a91ad134a8de79f7531ef0cde37dfd169 | [log] [tgz] |
---|---|---|
author | Mike Burrows <m3b@google.com> | Thu Jun 16 14:12:38 2016 -0700 |
committer | Mike Burrows <m3b@google.com> | Thu Jun 16 14:12:38 2016 -0700 |
tree | d70a048d9d155d3cd41827e9f29f07c8857ca1e3 | |
parent | 6497b74122ead111777e0d0de052e9a638b0b8da [diff] |
v.io/v23/context: add optional SetFinalizer to find context.CancelFunc leaks. The change adds a layer of indirection between v.io/v23/context's CancelFunc functions, and the cancelState calls, and uses runtime.SetFinalizer() on them to find leaks in which someone created a cancellable/deadline context, but drops the CancelFunc on the floor without calling it. To use, set the environment variable VCONTEXT_LEAK_CHECK to a file name, and run the Vanadium programme. Stack traces are appended to the file. For example: VCONTEXT_LEAK_CHECK=/tmp/leak.output jiri test run vanadium-go-test > /tmp/test.output 2>&1 If the environment variable is not set, the level of indirection is not used, so performance should not be greatly affected in that case. The change adds a set of benchmarks to verify this. Before: BenchmarkWithCancel-12 2000000 739 ns/op 280 B/op 6 allocs/op BenchmarkWithTimeout-12 1000000 1684 ns/op 496 B/op 11 allocs/op BenchmarkWithValue-12 5000000 267 ns/op 112 B/op 3 allocs/op After, without leak detection: BenchmarkWithCancel-12 2000000 695 ns/op 280 B/op 5 allocs/op BenchmarkWithTimeout-12 1000000 1803 ns/op 512 B/op 10 allocs/op BenchmarkWithValue-12 10000000 261 ns/op 112 B/op 3 allocs/op After, with leak detection: BenchmarkWithCancel-12 500000 2237 ns/op 488 B/op 7 allocs/op BenchmarkWithTimeout-12 1000000 3373 ns/op 720 B/op 12 allocs/op BenchmarkWithValue-12 5000000 272 ns/op 112 B/op 3 allocs/op Change-Id: Ia24c671ac8996916197fb693c928cbc8dac6ae86
This repository defines the Go APIs of Vanadium.