You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2018/07/17 00:25:25 UTC
mesos git commit: Improved performance of cgroups::read by verifying
after failure.
Repository: mesos
Updated Branches:
refs/heads/master d0c7d8993 -> 0ad92e2d9
Improved performance of cgroups::read by verifying after failure.
It turns out that cgroups::verify is expensive and leads to a severe
performance issue on the agent during container metrics collection
if there are a lot of containers on the agent. See MESOS-8418.
Since cgroups::verify serves to provide a helpful error message,
this patch preserves the error message, but only if the read fails.
Longer term, there probably needs to be some re-structuring of the
code to make verification caller-controlled, or perhaps the verify
code can occur consistently post-operation (as done in this patch),
or perhaps verify can be optimized substantially.
Review: https://reviews.apache.org/r/67923/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0ad92e2d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0ad92e2d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0ad92e2d
Branch: refs/heads/master
Commit: 0ad92e2d9e2152699ead84739e86f92edd1b462e
Parents: d0c7d89
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon Jul 16 17:22:45 2018 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Mon Jul 16 17:25:12 2018 -0700
----------------------------------------------------------------------
src/linux/cgroups.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0ad92e2d/src/linux/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp
index b12e63c..5c96484 100644
--- a/src/linux/cgroups.cpp
+++ b/src/linux/cgroups.cpp
@@ -917,12 +917,25 @@ Try<string> read(
const string& cgroup,
const string& control)
{
- Option<Error> error = verify(hierarchy, cgroup, control);
- if (error.isSome()) {
- return error.get();
+ Try<string> read = internal::read(hierarchy, cgroup, control);
+
+ // It turns out that `verify()` is expensive, so rather than
+ // verifying *prior* to the read, as is currently done for other
+ // cgroup helpers, we only verify if the read fails. This ensures
+ // we still provide a good error message. See: MESOS-8418.
+ //
+ // TODO(bmahler): Longer term, verification should be done
+ // explicitly by the caller, or its performance should be
+ // improved, or verification could be done consistently
+ // post-failure, as done here.
+ if (read.isError()) {
+ Option<Error> error = verify(hierarchy, cgroup, control);
+ if (error.isSome()) {
+ return error.get();
+ }
}
- return internal::read(hierarchy, cgroup, control);
+ return read;
}