[Toybox] [PATCH] Android roadmap update.

Rob Landley rob at landley.net
Fri May 6 20:01:42 PDT 2016


On 05/06/2016 07:29 PM, enh wrote:
> On Fri, May 6, 2016 at 5:04 PM, Rob Landley <rob at landley.net> wrote:
>> On 05/06/2016 11:25 AM, enh wrote:
>>> On Thu, May 5, 2016 at 8:04 PM, Rob Landley <rob at landley.net> wrote:
>>>> On 05/05/2016 11:25 AM, enh wrote:
>>>>> I removed iftop a while back but didn't remove it everywhere in the
>>>>> documentation. I switched over to toybox ps yesterday.
>>>>
>>>> Yay!
>>>>
>>>>> ---
>>>>>  www/roadmap.html | 10 +++++-----
>>>>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> If iftop is an iotop for network I/O, I've been meaning to do one of
>>>> those for a while now, but haven't looked up how yet.
>>>
>>> you can see ours (in the CL that removed it) here:
>>>
>>> https://android-review.googlesource.com/#/c/216389/1/toolbox/iftop.c
>>>
>>> it was nothing like the desktop one, which is all ASCII-art bar charts.
>>
>> Hmmm... This is basically taking snapshots of "ifconfig" output and
>> doing math on the RX BYTES and TX BYTES fields.
>>
>> Unfortunately parsing /proc/net/dev doesn't associate I/O with
>> processes, so gluing it into the existing toys/*/ps.c hairball wouldn't
>> make sense (since that's all about tracking per-process attributes).
>> That would be header info for the first couple lines of the screen, but
>> I still need the per-process data. (There's apparently stuff like
>> nethogs that finds it, I just haven't looked up how yet.)
> 
> Android has its own socket-tagging infrastructure for attributing
> network i/o to apps, so anything i know probably isn't very relevant
> elsewhere.

I'd happily do an if (CONFIG_ANDROID) { fetch it this way } else { fetch
it the other way } in get_ps() populating network traffic bits of the
slot[] array. (Under the same if (bits&_PS_NETSTUFF) guard to avoid
unnecessary work.)

I don't know WHY ps and top are so slow. I have a todo item to profile
them a bit and see if I can make it suck less. My co-workers at
se-instruments.com have been making fun of my netbook, which is the
computing equivalent of Columbo's car and trenchcoat (ok, I did ask them
for some fresh electrical tape for the battery), but one nice thing
about it (other than the portability) is when something is slow I NOTICE.

And top is a PIG. "toybox top -d 1" is eating 8% of the cpu on this
netbook while ubuntu's "top -d 1" is eating 3%. I know groveling around
in /proc is expensive but they both have to do it. I suspect washing all
the output through utf8 fontmetrics and escaping stuff (so if a username
is arabic or a process name has a newline in it, we don't wrap and
scroll the screen) is expensive. (It SHOULDN'T be, and probably is a lot
less with musl where it's utf8 only, but glibc has this horrible
setlocale() triggers a multiplexer requiring a decision about what
behavior to implement and the result has to be checked EVERY CHARACTER
for mbrtowc() and again in wcwidth() and really I should just do a
hardwired utf8 only version in lib.c to avoid traversing function
pointers to a new cache line... really I dunno if crunch_str() can be
made less terrible or if it's libc or what...)

Anyway, I got the behavior I want, and it's reasonably compact, but I'm
not happy with the speed.

Rob


More information about the Toybox mailing list