Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: An idea for fast "last-N-lines" read



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