[cgmanager-devel] read overhead
Serge Hallyn
serge.hallyn at ubuntu.com
Mon Dec 9 23:25:06 UTC 2013
Quoting Stéphane Graber (stgraber at ubuntu.com):
> On Mon, Dec 09, 2013 at 06:06:49PM -0500, Stéphane Graber wrote:
> > On Mon, Dec 09, 2013 at 04:56:30PM -0600, Serge Hallyn wrote:
> > > Hi,
> > >
> > > Google has said that they need to see 1000 reads/second from cgmanager.
> > > The code's not really in a state yet where it should be measured this
> > > way but I figured I'd get a baseline.
> > >
> > > On my laptop (3yo 8-core i7), simply reading memory.limit_in_bytes from
> > > bash 1000 times per second is not possible :) A little under 2 seconds
> > > is. Here are the three scripts I tried. The first simply reads
> > > the cgroup file 1000 times. The second uses dbus-send to send 1000
> > > requests to the cgroup manager. I would assume that using a custom
> > > client which uses the cgmanager-client.c (which I assume will become a
> > > library?) would turn out faster. The third is there for a fairer
> > > comparison to anything uses a daemon - it simply determins your
> > > current cgroup and prints out the memory.usage_in_bytes there. Any
> > > daemon which is answering a generic request will have to do something
> > > like that, of course.
> > >
> > > Now google have said they would simply read from the cgroup fs, and
> > > hoped to go through cgmanager for the writes - that of course is fine.
> > > There might be another way to achieve (on faster machines than my
> > > laptop :) 1000 r/s: we could have the cgmanager keep a short list of
> > > open files for certain requestors, so we could avoid some of the
> > > processing we are doing on every read. (Just handing an open fd to
> > > the caller probably is not ok, since the caller can reopen the file
> > > read-write if the file is owned by them. So to do that we'd have to
> > > assume that the caller is 100% trusted, which would be a very special
> > > case, and we may as well, at that point, let them mount the cgroupfs
> > > rw).
> > >
> > > Anyway, here are the 3 trivial scripts followed by the result of running
> > > 'time <script>'
> >
> > For a more realistic measurement of the processing time, can you try the
> > following?
> >
> > ---
> > #!/usr/bin/python3
> > import dbus
> > import time
> >
> > bus = dbus.connection.Connection("unix:path=/tmp/cgmanager")
> >
> > cgmanager = bus.get_object(None, '/org/linuxcontainers/cgmanager')
> > start_time = time.time()
> > for i in range(1000):
> > print(cgmanager.getValue("memory", "", "memory.usage_in_bytes"))
> > end_time = time.time()
> > print("Total time: %s" % (end_time - start_time))
> > ---
Wow that's fast.
serge at sergelap:~/src/cgmanager$ time sudo ./timeme4.py
Total time: 0.4718151092529297
real 0m0.540s
user 0m0.256s
sys 0m0.055s
So I guess let's just finish basic functionality and then do some real
testing :)
-serge
PS - Thanks for test, that'll be useful boilerplate later on.
More information about the cgmanager-devel
mailing list