From: Bart Schaefer <schaefer@brasslantern.com>
To: Sebastian Gniazdowski <psprint3@fastmail.com>, zsh-workers@zsh.org
Subject: Re: An idea for fast "last-N-lines" read
Date: Wed, 22 Mar 2017 20:53:04 -0700 [thread overview]
Message-ID: <170322205304.ZM5853@torch.brasslantern.com> (raw)
In-Reply-To: <1490076282.321781.918060736.22D2C432@webmail.messagingengine.com>
On Mar 20, 11:04pm, Sebastian Gniazdowski wrote:
}
} I read somewhere that to read "last-N-lines" it is good to memory-map
} the file. Cannot check with Zsh [...]
} - apparently because it memory-maps the file on each newline check.
Indeed, the mapfile module doesn't help much after the initial file
read because zsh has no mechanism for holding a reference to the
mapped block of memory. It's mostly for quickly copying the entire
file into and out of regular heap.
This could, however, be made a lot better, e.g. by introducing a cache
of mapped files into mapfile.c and causing get_contents() to first use
the cache (and setpmmapfile to update it, unsetpmmapfile to erase an
entry from it) before resorting to remapping the actual file.
} I'm thinking about: $(<10<filepath) syntax
I'm not thrilled about adding new syntax for this, and anyway that
conflicts with multios semantics.
} BTW, (@f) skips trailing \n\n... That's quite problematic and there's
} probably no workaround?
In double quotes, (@f) retains empty elements, which includes making
empty elements out of trailing newlines. However, there is no way to
get $(<file) [or $(<<<string) etc.] to retain trailing newlines, which
is most likely what's misleading you.
next prev parent reply other threads:[~2017-03-23 3:59 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 [this message]
[not found] ` <etPan.58d39baa.74b0dc51.10ab3@MacMini.local>
2017-03-23 10:17 ` Sebastian Gniazdowski
2017-03-23 16:46 ` Bart Schaefer
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=170322205304.ZM5853@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=psprint3@fastmail.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).