Subject: bug#19393: 25.0.50; Emacs cannot determine coding system of ISO-8859 encoded files

From: Wolfgang Jenkner <[email-masked]>
Date: Sat, 20 Dec 2014 04:21:54 +0100

On Thu, Dec 18 2014, Eli Zaretskii wrote:

> Then it's probably some inefficiency in insert-file-contents, when it
> is called to revert a buffer.  If you have time, please take a look
> what happens there, I suspect we reallocate the buffer in very small
> chunks, instead of doing it with larger increments.  (With compressed
> files, it's hard to do, because the size of the uncompressed file is
> not known in advance.)

I have been looking into this with dtrace and what is sure is that
a large amount of data (increasing up to the order of magnitude of the
buffer size) is memcpy'd again and again as a result of mmap_realloc
being called by enlarge_buffer_text.  Apparently, the latter is called
for buffer gap handling which is triggered by decode_coding_c_string (or
rather decode_coding_object) in insert-file-contents.  So it seems that
the effect on memory of this innocent-looking loop there is enormously
magnified.

But I have to look at the source more closely (not that I expect to get
any idea how to fix this, though).