The logger meets linux-kernel
The logger meets linux-kernel
Posted Jan 5, 2012 0:16 UTC (Thu) by dlang (guest, #313)In reply to: The logger meets linux-kernel by neilbrown
Parent article: The logger meets linux-kernel
however, I'll bet that you are really talking about much lower data rates, I'd be surprised if you needed much over 100 logs/sec and amazed if you need over 1000 logs/sec (remember, we're not talking about logs from the kernel here, we're talking about logs from userspace, the type of thing that is sent to syslog on a traditional linux distro, or is written to a app-specific log file)
the fact that the kernel is involved at all is simply a desire from the android developers to avoid having a userspace daemon.
for the trivial capabilities that the logger currently has (listen to a filesystem name, accept anything written to it into a circular buffer, and regurgitate the buffer if requested), it seems to me that a pretty trivial userspace daemon should be able to do this. I still haven't seen any explanation (other than the "we didn't want another daemon running" one) for why the kernel should be involved at all.
Posted Jan 5, 2012 0:52 UTC (Thu)
by neilbrown (subscriber, #359)
[Link] (1 responses)
I don't think we are just talking about the stuff that a normal distro sends to syslog. Brian observed that app developers complain that other apps send too many message to the log so "their" much more important messages fall off the end of the log. This suggests a high rate of log-spam.
The kernel is *always* involved. Even if you use shared memory, who do you think it is that maps the memory into each process on the relevant page faults?
Yes: by pre-faulting large shared memory images and using futexs you could interleave logs from multiple processes with little interaction with the kernel (if each process ran on its own processor) but that doesn't fit the android security model. Each process has it's own uid and doesn't trust other processes (or at least the log system doesn't trust any of it's clients beyond the fixed API). So shared-memory logging doesn't really meet the need.
Posted Jan 5, 2012 1:26 UTC (Thu)
by dlang (guest, #313)
[Link]
given that they have a rather tiny fixed-size buffer (256K was mentioned), having enough logs generated to fall off the end does not really equate to that large a data rate.
But even if high performance is needed (and note that I am still not agreeing that it is), that doesn't, by itself, justify implementing something in the kernel. That's why we no longer have the tux webserver in the kernel, and there have been many other things proposed that "required" kernel level implementations for performance reasons, that ended up not going in to the kernel.
the fact that we haven't been able to get anyone to talk about data rates other than the very generic "overrunning a 256K buffer in seconds" doesn't do much to justify this going into the kernel.
I'll bet just about any linux system generates > 256k of syslog messages in 'seconds' as it boots up.
In fact, I have a server that I just rebooted, in it's first second, syslog shows >100K of message data in syslog (and this is a pretty stripped down kernel and boot, I'll bet standard distro kernels end up logging quite a bit more)
Posted Jan 5, 2012 16:41 UTC (Thu)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link] (12 responses)
Posted Jan 5, 2012 17:39 UTC (Thu)
by dlang (guest, #313)
[Link] (11 responses)
and in any case, where are the numbers?
how much traffic are we actually talking about here, what how much processor does it take to do this in kernel space, how much more in userspace (and even if it's 100x more, is it enough to actually matter?)
Posted Jan 5, 2012 18:03 UTC (Thu)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link] (10 responses)
So the sensitivity to CPU consumption is way higher than I would have guessed a couple of years ago. In addition, there are other well-known issues that arise when relying on a separate daemon in addition to efficiency. I have run into them many times over the years (make that decades), and I would guess that you have as well.
It is instructive to turn the question around. First, start with the assumption that the Android guys actually are competent in their area of expertise. Then ask yourself why a userspace daemon might be problematic for them.
Posted Jan 5, 2012 18:58 UTC (Thu)
by dlang (guest, #313)
[Link] (9 responses)
I really believe that this is premature optimization and micro-benchmark optimization.
to restate an example I've posted before, several years ago at $work, the engineers ran a benchmark that showed a 60x performance improvement (from 30 seconds to .5 seconds) for a read_config() function by creating a shared memory segment and populating that rather than reading from disk.
the problem is that this benchmark was for 100,000 reads of the config file, and the real-world usage showed that this function was executed 50,000 times in an hour across >50 machines. This 6-month engineering project saved a total of 15 cpu seconds in a peak hour across 200 cores.
sometimes "it's faster", even for high multipliers of how much faster just don't matter because the function just isn't called frequently enough.
I have some firewalls that run 'inefficient' fork-for-every-connection proxies (horribly inefficient, right), but on a peak day these systems (on low-end hardware) still don't hit a loadaverage of 0.2, so the inefficiency really doesn't matter.
application logging just isn't that heavy, even on a 'slow' cell phone processor.
Posted Jan 5, 2012 20:48 UTC (Thu)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link] (7 responses)
Fair enough.
Just don't be surprised when others return the favor by being unwilling to assume that you are competent within your area of expertise.
Posted Jan 5, 2012 21:26 UTC (Thu)
by dlang (guest, #313)
[Link] (6 responses)
In general, this is exactly how it works in kernel development.
Posted Jan 5, 2012 22:10 UTC (Thu)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link] (5 responses)
How did you determine that the Android guys' avoidance of user-mode daemons was strictly due to performance issues?
Posted Jan 5, 2012 22:51 UTC (Thu)
by dlang (guest, #313)
[Link] (4 responses)
Posted Jan 5, 2012 23:13 UTC (Thu)
by dlang (guest, #313)
[Link] (3 responses)
Posted Jan 6, 2012 16:35 UTC (Fri)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link] (2 responses)
One caution: It is difficult to get requirements from the Android guys. Not because they are uncooperative, but because they are only conscious of some of the requirements. The rest are so second-nature to them that they don't think of them. This means that working on a suitable replacement is an iterative process, where you learn the requirements by repeatedly implementing your best guess at each point in time.
John Stultz has gone through much of this process with his alarm-timers work, and he does appear to be getting close to a solution that is useful to both the Android guys and to non-smartphone software.
I have been on both sides of this. Back in the 1990s, those of us at Sequent habitually wrote parallel programs, but could not describe how to do it to others. We did try, but the results were not so good. Instead, we used apprenticeship-style training: We put the new guy in a cube surrounded by people who knew parallel programming, and after a few months, the new guy would have no problem writing competent parallel code.
I was on the other side while gathering wakelock requirements in 2010 and 2011. The “Avoid Thundering Herds of Timers” requirement is an example of an important requirement that was not at all obvious to me, but so obvious to the Android guys that they didn't think to state it.
Sort of like you would probably not see the need to put “the acceleration of gravity at the site is 9.8 meters per second squared” when creating specs for a builder. ;–)
Posted Jan 12, 2012 23:20 UTC (Thu)
by Kluge (subscriber, #2881)
[Link] (1 responses)
Does this mean that Android developers are from Mars, kernel hackers from Venus? ;-)
Posted Jan 13, 2012 0:54 UTC (Fri)
by PaulMcKenney (✭ supporter ✭, #9624)
[Link]
Posted Jan 18, 2012 6:02 UTC (Wed)
by kevinm (guest, #69913)
[Link]
Rather, it's the fact that every extra cycle wasted is an extra cycle that the CPU must remain in a higher power state, and thus represents an incremental hit to the battery life. Recall in particular that context-switching from one userspace process to another requires a cache-flush on older ARM processors.
The logger meets linux-kernel
The logger meets linux-kernel
The logger meets linux-kernel
The logger meets linux-kernel
What matters
What matters
What matters
What matters
What matters
What matters
What matters
It would be really cool if you did get a chance to try this out!
What matters
What matters
Mars and Venus
What matters