coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] seq: speed up the common case by 25x


From: Pádraig Brady
Subject: Re: [PATCH] seq: speed up the common case by 25x
Date: Fri, 01 Apr 2011 11:14:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 01/04/11 10:59, Jim Meyering wrote:
> Pádraig Brady wrote:
> 
>> On 01/04/11 10:20, Jim Meyering wrote:
>>> Pádraig Brady wrote:
>>>>     seq: speed up the common case by 560%
>>>>
>>>>     * seq.c (print_range): Print a range of numbers
>>>>     without using if statements for speed.
>>>>     (print_long_range): Print a range of numbers
>>>>     using the unix paradigm of using other utils
>>>>     that do it better.
>>>
>>> Great idea.
>>
>>> I get this:
>>>
>>>   $ env time ./seq 10000000 > /dev/null
>>>   0.50user 0.06system 0:00.20elapsed 273%CPU (0avgtext+0avgdata 
>>> 4800maxresident)k
>>>   ...
>>>
>>> Compare with the old version's time:
>>>
>>>   5.06user 0.00system 0:05.08elapsed 99%CPU (0avgtext+0avgdata 
>>> 2608maxresident)k
>>>
>>> So here I benefit from parallelism, and end up with not just 560% (5.6x)
>>> but a 25x(!) speed-up (on an i7-970).
>>
>> My April fool's joke has spectacularly backfired.
> 
> Too close to the truth.
> ;-)

LOL. I'm unsure if you've got me back with
my own whacky patch. Argh.

> However, the point is very valid.
> seq can and should be doing much better in that case.
> 
> Maybe librarify cat -n's code and use it from both?
> We'd lose parallelism, but also skip the fork+inter-process I/O.

Yep, a sane approach is to forget the recursive whackyness,
and generalize the cat -n code along the lines of the original
ascii manipulations in getlimits.c.  That would give speed
and limitless numbers and no dependencies between tools.
That would take more than the 5 mins I spent on this,
and Paul said he might like to give it as a project to
a student, so I'll leave it for the moment.

At least we now have a benchmark to beat. 2500%!

lol
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]