zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: An idea for fast "last-N-lines" read
Date: Thu, 23 Mar 2017 09:46:02 -0700	[thread overview]
Message-ID: <170323094602.ZM8458@torch.brasslantern.com> (raw)
In-Reply-To: <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.


      reply	other threads:[~2017-03-23 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21  6:04 Sebastian Gniazdowski
2017-03-23  3:53 ` Bart Schaefer
     [not found]   ` <etPan.58d39baa.74b0dc51.10ab3@MacMini.local>
2017-03-23 10:17     ` Sebastian Gniazdowski
2017-03-23 16:46       ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=170323094602.ZM8458@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).