From: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Handling large files with emacs lisp?
Date: Tue, 4 Jun 2013 14:52:55 +0200 [thread overview]
Message-ID: <CANtbJLEpp8J=Fo4=KiUAEuYk8RGwQF8ce3_TmP1RZZrMAt1+6Q@mail.gmail.com> (raw)
Hello!
Is there a method in emacs lisp to handle large files (hundreds of MB)
efficiently? I am looking specifically for a function that allows
processing file contents either sequentially or (better) with random
access.
Looking through the code of `find-file' I found that
`insert-file-contents' and `insert-file-contents-literally' seem to be
pretty much the most low-level functions available to emacs-lisp. When
files go towards GB size however, inserting file contents is
undesirable even assuming 32bit emacs were able to handle such large
buffers.
Using the BEG and END parameters of `insert-file-contents' however has
a linear time-dependence on BEG. So implementing buffered file
processing for large files by keeping only parts of the file in a
temporary buffer doesn't seem feasible either.
I'd also be interested why there is this linear time dependence. Is
this a limitation of how fseek works or of how `insert-file-contents'
is implemented? I've read[1] that fseek "just updates pointers", so
random reads in a large file, especially on an SSD, should be
constant-time, but I couldn't find further verification.
kind regards, Klaus
PS: I'm well aware that I'm asking for something, that likely wasn't
within the design goals of emacs lisp. It is interesting to push
the limits though ;)
------------------------------------------------------------
[1] https://groups.google.com/d/msg/comp.unix.aix/AXInTbcjsKo/qt-XnL12upgJ
next reply other threads:[~2013-06-04 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 12:52 Klaus-Dieter Bauer [this message]
2013-06-04 14:46 ` Handling large files with emacs lisp? Jambunathan K
2013-06-05 10:47 ` Klaus-Dieter Bauer
2013-06-04 22:02 ` Stefan Monnier
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='CANtbJLEpp8J=Fo4=KiUAEuYk8RGwQF8ce3_TmP1RZZrMAt1+6Q@mail.gmail.com' \
--to=bauer.klaus.dieter@gmail.com \
--cc=help-gnu-emacs@gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.