Micro benchmarks for containerd. (#244)
This is the first in a series of micro benchmarks for containerd. Performance measurement will use containerd objects and methods that are not dependent on the grpc API and dont require the daemon to the running. Test will require containerd-shim and runc. The motivation is to understand the baseline performance at the lowest containerd layer. A natural extension to this effort would be to write macro benchmarks which would include API and daemon. Note: - Currently measures only one workload (busybox sh) start times. Will add other bundles and args soon. - Can use integration-test utils for bundle processing. However, json marshal/unmarshal is currently timing out standard benchmark times. So going with default spec for now. Sample run: BenchmarkBusyboxSh-4 / # / # / # 2 576013841 ns/op ok github.com/docker/containerd/runtime 1.800s Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
parent
7fa8fc1477
commit
24144682a0
5 changed files with 265 additions and 41 deletions
|
@ -8,14 +8,10 @@ import (
|
|||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
utils "github.com/docker/containerd/testutils"
|
||||
ocs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
var (
|
||||
bundlesDir = filepath.Join("test-artifacts", "oci-bundles")
|
||||
refOciSpecsPath = filepath.Join(bundlesDir, "config.json")
|
||||
)
|
||||
|
||||
type OciProcessArgs struct {
|
||||
Cmd string
|
||||
Args []string
|
||||
|
@ -48,7 +44,7 @@ func untarRootfs(source string, destination string) error {
|
|||
func CreateBundleWithFilter(source, name string, args []string, filter func(spec *ocs.Spec)) error {
|
||||
// Generate the spec
|
||||
var spec ocs.Spec
|
||||
if f, err := os.Open(refOciSpecsPath); err != nil {
|
||||
if f, err := os.Open(utils.RefOciSpecsPath); err != nil {
|
||||
return fmt.Errorf("Failed to open default spec: %v", err)
|
||||
} else {
|
||||
if err := json.NewDecoder(f).Decode(&spec); err != nil {
|
||||
|
@ -63,7 +59,7 @@ func CreateBundleWithFilter(source, name string, args []string, filter func(spec
|
|||
filter(&spec)
|
||||
}
|
||||
|
||||
bundlePath := filepath.Join(bundlesDir, name)
|
||||
bundlePath := filepath.Join(utils.BundlesRoot, name)
|
||||
nb := Bundle{source, name, spec, bundlePath}
|
||||
|
||||
// Check that we don't already have such a bundle
|
||||
|
@ -78,7 +74,7 @@ func CreateBundleWithFilter(source, name string, args []string, filter func(spec
|
|||
// Nothing should be there, but just in case
|
||||
os.RemoveAll(bundlePath)
|
||||
|
||||
if err := untarRootfs(filepath.Join(archivesDir, source+".tar"), bundlePath); err != nil {
|
||||
if err := untarRootfs(filepath.Join(utils.ArchivesDir, source+".tar"), bundlePath); err != nil {
|
||||
return fmt.Errorf("Failed to untar %s.tar: %v", source, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,10 @@ import (
|
|||
"google.golang.org/grpc/grpclog"
|
||||
|
||||
"github.com/docker/containerd/api/grpc/types"
|
||||
utils "github.com/docker/containerd/testutils"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
var (
|
||||
outputDirFormat = filepath.Join("test-artifacts", "runs", "%s")
|
||||
archivesDir = filepath.Join("test-artifacts", "archives")
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
check.TestingT(t)
|
||||
}
|
||||
|
@ -102,14 +98,6 @@ func (cs *ContainerdSuite) ContainerdEventsHandler(events types.API_EventsClient
|
|||
}
|
||||
}
|
||||
|
||||
// generateReferencesSpecs invoke `runc spec` to produce the baseline
|
||||
// specs from which all future bundle will be generated
|
||||
func generateReferenceSpecs(destination string) error {
|
||||
specs := exec.Command("runc", "spec")
|
||||
specs.Dir = destination
|
||||
return specs.Run()
|
||||
}
|
||||
|
||||
func (cs *ContainerdSuite) StopDaemon(kill bool) {
|
||||
if cs.cd == nil {
|
||||
return
|
||||
|
@ -181,28 +169,29 @@ func (cs *ContainerdSuite) SetUpSuite(c *check.C) {
|
|||
bundleMap = make(map[string]Bundle)
|
||||
cs.eventFilters = make(map[string]func(event *types.Event))
|
||||
|
||||
// Get our CWD
|
||||
if cwd, err := os.Getwd(); err != nil {
|
||||
c.Fatalf("Could not determine current working directory: %v", err)
|
||||
} else {
|
||||
cs.cwd = cwd
|
||||
// Get working directory for tests
|
||||
wd := utils.GetTestOutDir()
|
||||
if err := os.Chdir(wd); err != nil {
|
||||
c.Fatalf("Could not change working directory: %v", err)
|
||||
}
|
||||
cs.cwd = wd
|
||||
|
||||
// Clean old bundles
|
||||
os.RemoveAll(bundlesDir)
|
||||
os.RemoveAll(utils.BundlesRoot)
|
||||
|
||||
// Ensure the oci bundles directory exists
|
||||
if err := os.MkdirAll(bundlesDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(utils.BundlesRoot, 0755); err != nil {
|
||||
c.Fatalf("Failed to create bundles directory: %v", err)
|
||||
}
|
||||
|
||||
// Generate the reference spec
|
||||
if err := generateReferenceSpecs(bundlesDir); err != nil {
|
||||
if err := utils.GenerateReferenceSpecs(utils.BundlesRoot); err != nil {
|
||||
c.Fatalf("Unable to generate OCI reference spec: %v", err)
|
||||
}
|
||||
|
||||
// Create our output directory
|
||||
cs.outputDir = fmt.Sprintf(outputDirFormat, time.Now().Format("2006-01-02_150405.000000"))
|
||||
cs.outputDir = fmt.Sprintf(utils.OutputDirFormat, time.Now().Format("2006-01-02_150405.000000"))
|
||||
|
||||
cs.stateDir = filepath.Join(cs.outputDir, "containerd-master")
|
||||
if err := os.MkdirAll(cs.stateDir, 0755); err != nil {
|
||||
c.Fatalf("Unable to created output directory '%s': %v", cs.stateDir, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue