Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: An idea for fast "last-N-lines" read
- X-seq: zsh-workers 40889
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: An idea for fast "last-N-lines" read
- Date: Thu, 23 Mar 2017 09:46:02 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=Br44/VTY6c5qmLN2MhQA5Y7upjX7dlvFe/Hn3wUTPTo=; b=0XrUf+bUHnBmzM1W+jxHCpfSmU0cDfp7WHEG/1wRfRa3YH1IIKVWG/tg8gitYOjom/ GVeubV2zsyyVCqm7LqrfRNkx+rg508AZa/Y2C+gAL9302V+N7y7JkbtzG0ARw7oW6uLS +fZ/D1X67HRK1+Q7HxQ1rNWDKM1mpLvVpgpz7emlp6/70SqCKirmAHQvljgUFyn9Fan4 Fc/dpNIHumneUOe2kdYB3foIkROyjT12IebEPYi6zGeQ8ilG936Aac6VWoxyQYn3C7oN mQmiOPI26DIgbpsol1ZmAOji6hLIFss5crcwqJa8wIJI28EXPLgiCWcpwo+3o8gyafq6 QMwQ==
- In-reply-to: <etPan.58d3a0b6.19495cff.10ab3@MacMini.local>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1490076282.321781.918060736.22D2C432@webmail.messagingengine.com> <170322205304.ZM5853@torch.brasslantern.com> <etPan.58d39baa.74b0dc51.10ab3@MacMini.local> <etPan.58d3a0b6.19495cff.10ab3@MacMini.local>
On Mar 23, 11:17am, Sebastian Gniazdowski wrote:
} Subject: Re: An idea for fast "last-N-lines" read
}
} % lines=(); typeset -F SECONDS=0; lines=( "${(@f)${${mapfile[input.db]}[-250000,-1]}}" ); echo $SECONDS, ${#lines}
} 0.3925410000, 1536
}
} I would expect mapfile to perform little better.
The whole file has to get metafied by heap copy before subscripting can
be applied ... mapfile was a lot more efficient before we began to need
to store parameters in metafied state.
Other parameter ops are also going to do pass-by-value even if the base
reference is mmap'd, so there will be some constructs where the whole
file is copied over and over. Nothing to be done about that without a
full rewrite of subst.c ...
} Wonder how would sysread perform, and what about metafication when using it.
Metafication should be OK, it makes a metafied heap copy just as does
mapfile. if you first "sysseek -w end 25000" and then "sysread -s 25000"
it should be quite fast, but reading an entire large file may be slower
than with mapfile.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author