[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Recommendations on my upcoming Lua presentation?
- From: Chris Babcock <cbabcock@...>
- Date: Tue, 1 Feb 2011 19:29:02 -0700
On Tue, Feb 1, 2011 at 4:54 PM, Steve Litt <slitt@troubleshooters.com> wrote:
> Devils advocate:
>
> Why use filters in Lua coroutines when you could do:
>
> grep -v .jpg$ access_log | grep -v .gif$ | grep -v .class$ | \
> calculate.lua | add_hdrs_and_footers.lua | \
> sort | report.lua > traffic_report.txt
>
> The preceding uses code pieces tested over and over again throughout the
> years, and it either uses several of your processors or if you have two few it
> uses tried and true Linux multitasking. Seems to me with that available it
> makes no sense to debug your own coroutines.
>
> Thanks
>
> SteveT
Short answers, because you're doing a short presentation...
- Line length limit.
- Reusability.
- Runs as one process.
Instead of 3 instances of grep and 3 instances of the Lua interpreter
running, you have one instance of Lua running for the task. If the
application is demanding then you may want to conserve processes and
file handles... Yielding a coroutine is more robust and faster/less
overhead than passing a stream through a pipe.
Also coroutines can have side effects.
Chris
--
51st century guy