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

Use faster mountinfo parser (part 1) #2256

Merged
merged 6 commits into from
Mar 27, 2020

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Mar 14, 2020

This is part 1 of improving runc wrt /proc/self/mountinfo parsing (and an alternative to #2255).

It needs improvements because:

  • the current code has 5 different implementations of runc parser
  • a single runc run command reads mountinfo from from 72 to 116 times (depending on whether --systemd-cgroup is set) on my system.
  • reading mountinfo from the kernel might be slow if there are many containers running (and thus many mounts)
  • reading mountinfo might also be racy (see https://github.com/kolyshkin/procfs-test)

This PR

The new parser itself is up to 8x faster than the one removed; in addition, it implements mountinfo filters that may result in additional savings (faster, less garbage to collect).

History

My future plans (not in this PR) are

  • part 2: make other runc code that parses mountinfo on its own to use the above package
  • part 3: look into cgroups code, trying to minimize calls to parse mountinfo

@kolyshkin
Copy link
Contributor Author

This is failing because we still use golang 1.12 :(

@kolyshkin
Copy link
Contributor Author

Added a temporary commit switching to golang 1.13. Ultimately, we need to merge #2234 and #2239

Dockerfile Outdated
@@ -1,4 +1,4 @@
FROM golang:1.12-stretch
FROM golang:1.14-stretch
Copy link
Member

Choose a reason for hiding this comment

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

Why 1.14?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either 1.13 or 1.14 should work just fine. As 1.13 will eventually be unsupported, I'm jumping straight to 1.14. Can use 1.13 as well here, let me know if you want it that way.

Ideally we should merge #2239 first and just rebase this one on top of it, but it's still marked as draft by @thaJeztah.

Copy link
Member

Choose a reason for hiding this comment

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

1.14 has breaking changes on SIGURG&EINTR stuff https://golang.org/doc/go1.14#runtime

Copy link
Member

Choose a reason for hiding this comment

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

It was marked "draft", because I separated it from #2234. Hopefully that one could be merged soon, and I'll rebase #2239

@kolyshkin kolyshkin changed the title Use faster mountinfo parser Use faster mountinfo parser (part 1) Mar 18, 2020
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Please roll back to go 1.13

@kolyshkin
Copy link
Contributor Author

Please roll back to go 1.13

done

@kolyshkin
Copy link
Contributor Author

@opencontainers/runc-maintainers PTAL

@kolyshkin
Copy link
Contributor Author

kolyshkin commented Mar 19, 2020

IDK what's going on on travis, it doesn't like oldstable as go version. Works fine on my laptop though, and same gimme version.

My laptop:

$ gimme -r oldstable
1.13.8
$ gimme -V
v1.5.3

Travis:

gimme version
v1.5.3
...
gimme: version specifier 'oldstable' unknown
error: GIMME_GO_VERSION not recognized as valid
  got: oldstable
Failed to run gimme
The command "travis_setup_go" failed and exited with 86 during .

Anyway I'll just use 1.13.x and stable (which currently equals 1.14.x)

@kolyshkin kolyshkin force-pushed the mountinfo-alt branch 2 times, most recently from 83bb000 to 2ae97a2 Compare March 19, 2020 16:30
@kolyshkin
Copy link
Contributor Author

Some glitch in CI, rebasing to re-trigger it

gzip: stdin: not in gzip format
1452tar: Child returned status 1
1453tar: Error is not recoverable: exiting now
1454The command '/bin/sh -c mkdir -p /usr/src/criu && curl -sSL https://github.com/checkpoint-restore/criu/archive/${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 && cd /usr/src/criu && make install-criu && rm -rf /usr/src/criu' returned a non-zero code: 2

@kolyshkin
Copy link
Contributor Author

CI is good now, was a glitch

.travis.yml Outdated
name: "verify-dependencies"
script:
- make verify-dependencies
- go: 1.12.x
- go: stable
Copy link
Member

Choose a reason for hiding this comment

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

stable -> 1.13.x ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, currently stable means 1.14.x. I didn't want to use an explicit version here since it will need to be changed every once in a while, but an implicit version like stable can stay as is.

Do you want it to be explicit?

Copy link
Member

Choose a reason for hiding this comment

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

We aren't ready for 1.14 yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is CI only and it passes.

OK I'll switch to explicitly 1.13

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Run CI with go 1.13 and 1.14 (aka "stable").

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Delete libcontainer/mount in favor of github.com/moby/sys/mountinfo,
which is fast mountinfo parser.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. rootfs is already validated to be kosher by (*ConfigValidator).rootfs()

2. mount points from /proc/self/mountinfo are absolute and clean, too

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Mar 21, 2020

LGTM

Approved with PullApprove

@mrunalp
Copy link
Contributor

mrunalp commented Mar 24, 2020

LGTM

Approved with PullApprove

@mrunalp
Copy link
Contributor

mrunalp commented Mar 24, 2020

@crosbymichael @cyphar @giuseppe ptal.

@AkihiroSuda
Copy link
Member

@mrunalp Can we merge this, or do you want one more LGTM?

@mrunalp mrunalp merged commit 53ad1d5 into opencontainers:master Mar 27, 2020
@kolyshkin kolyshkin deleted the mountinfo-alt branch March 30, 2020 16:02
kolyshkin added a commit to kolyshkin/runc that referenced this pull request Apr 3, 2020
Make use of errors.Is() and errors.As() where appropriate to check
the underlying error. The biggest motivation is to simplify the code.

The feature requires go 1.13 but since merging opencontainers#2256 we are already
not supporting go 1.12 (which is an unsupported release anyway).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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.

4 participants