Bug 6914 - tail is inefficient and pops up in top
Summary: tail is inefficient and pops up in top
Status: RESOLVED INVALID
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 enhancement
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-21 20:37 UTC by yuri
Modified: 2014-02-26 00:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yuri 2014-02-21 20:37:49 UTC
I am running this command:
# cat /dev/urandom | hexdump -C | tail -n100000

On Android tail command pops up in top with ~75% CPU.
As a comparison, on FreeBSD hexdump pops up in profile with ~100% CPU, as it should be.

Generating the hex dump should require much more work, because the program needs to print separate bytes as combinations of 2-3 characters. And tail only needs to scan a buffer for a newline character, and keep the appropriate rolling buffer.

tail needs to be improved to work faster.

NOTE On Android tail takes 75% CPU and not 100% CPU because the random number generator in Android is also slow (not a BusyBox problem). Otherwise it would have been 100% as well.


# tail --help
BusyBox v1.21.0 (2013-07-08 16:00:47 CEST) multi-call binary.
Comment 1 Denys Vlasenko 2014-02-25 12:19:59 UTC
I don't want to have 300 bugs "applet <foo> needs to be improved".
Comment 2 yuri 2014-02-25 19:28:15 UTC
Ok, but how is this going to be fixed? This must be a problem specific to tail.
Comment 3 Denys Vlasenko 2014-02-25 20:18:29 UTC
(In reply to comment #2)
> Ok, but how is this going to be fixed? This must be a problem specific to tail.

Maybe you can help?
Comment 4 yuri 2014-02-25 21:00:09 UTC
Also I don't think such Bug should be closed as invalid, because it is valid. It should rather be set to 'wishlist' status.
Comment 5 Denys Vlasenko 2014-02-25 21:20:28 UTC
(In reply to comment #4)
> Also I don't think such Bug should be closed as invalid, because it is valid.
> It should rather be set to 'wishlist' status.

Look. So far you did nothing to help with this "bug" or "performance problem" or whatever you call it.
You can't demand that *other people* work on things *you* consider to be problems.
If you have a patch, please post it.
Otherwise, stop pushing me.
Comment 6 yuri 2014-02-25 21:26:28 UTC
I reported the problem. This is the first step. And the problem is valid.
The second step is to look into it. I said I will help.

You closed the Bug as invalid, this doesn't make sense, because it is valid.

I am not pushing you to fix anything, just to keep correct records.
Comment 7 yuri 2014-02-26 00:04:58 UTC
I did valgrind profiling, and found that most time is spent in memmove function.
tail should not call memmove at all.