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

From: Wolfgang Jenkner <[email-masked]>
Date: Thu, 18 Dec 2014 02:47:41 +0100

On Wed, Dec 17 2014, Eli Zaretskii wrote:

>> On Wed, Dec 17 2014, Eli Zaretskii wrote:
>> 
>> > What is the system where you observed the 20-minute delay?  And what
>> > version of Emacs was that?
>> 
>> FreeBSD 10 on amd64
>
> That's what I thought.  AFAIK, FreeBSD systems use mmap(2) explicitly
> for buffer memory allocation, and that could be slow when we need to
> repeatedly reallocate buffer text and memmove the text between old and
> new.
>
>> but the emacs versions I have are more than a month old, so I'll
>> bootstrap from a current git checkout and try again.
>
> If I'm right, this won't change the result.

You are right, of course (it took around 15 minutes system+user time).

So, I tried

--8<---------------cut here---------------start------------->8---
diff --git a/configure.ac b/configure.ac
index 010abc8..de1c5e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2127,7 +2127,7 @@ fi
 
 use_mmap_for_buffers=no
 case "$opsys" in
-  cygwin|mingw32|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
+  cygwin|mingw32|irix6-5) use_mmap_for_buffers=yes ;;
 esac
 
 AC_FUNC_MMAP
--8<---------------cut here---------------end--------------->8---

However, this still took around 10 minutes (I tested with emacs -Q in
both cases, of course).

I give samples of the recurring sequence of syscalls (as reported by
truss) in both cases below.

Here's the current default for FreeBSD.

  Should Emacs use the GNU version of malloc?             yes
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         yes

--8<---------------cut here---------------start------------->8---
sigprocmask(SIG_BLOCK,SIGINT|SIGALRM,0x0)	 = 0 (0x0)
clock_gettime(0,{1418846146.702726599 })	 = 0 (0x0)
ktimer_settime(0x3,0x1,0x7ffffffece50,0x0,0x0,0x0) = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,SIGINT|SIGALRM)	 = 0 (0x0)
nanosleep({0.000001000 })			 = 0 (0x0)
mmap(0x0,28815360,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x8108ec000,28798976)			 = 0 (0x0)
read(9,"\t????\n"Esperan\M-ga" (2002) {("...,65536) = 65536 (0x10000)
mmap(0x0,28831744,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34608795648 (0x80ed85000)
munmap(0x80d20a000,28815360)			 = 0 (0x0)
mmap(0x0,28848128,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34637627392 (0x810904000)
munmap(0x80ed85000,28831744)			 = 0 (0x0)
mmap(0x0,28864512,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810904000,28848128)			 = 0 (0x0)
mmap(0x0,28880896,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34608844800 (0x80ed91000)
munmap(0x80d20a000,28864512)			 = 0 (0x0)
read(9," SportsCentury" (1999) {Seabiscu"...,65536) = 65536 (0x10000)
mmap(0x0,28897280,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34637725696 (0x81091c000)
munmap(0x80ed91000,28880896)			 = 0 (0x0)
mmap(0x0,28913664,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x81091c000,28897280)			 = 0 (0x0)
mmap(0x0,28930048,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34608893952 (0x80ed9d000)
munmap(0x80d20a000,28913664)			 = 0 (0x0)
mmap(0x0,28946432,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34637824000 (0x810934000)
munmap(0x80ed9d000,28930048)			 = 0 (0x0)
read(9,"a es mi historia" (2001) {La vid"...,65536) = 65536 (0x10000)
mmap(0x0,28962816,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810934000,28946432)			 = 0 (0x0)
mmap(0x0,28979200,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34608943104 (0x80eda9000)
munmap(0x80d20a000,28962816)			 = 0 (0x0)
mmap(0x0,28999680,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34637922304 (0x81094c000)
munmap(0x80eda9000,28979200)			 = 0 (0x0)
mmap(0x0,29016064,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x81094c000,28999680)			 = 0 (0x0)
read(9,"\t1999\n"Esti showder" (1999) {("...,65536) = 65536 (0x10000)
mmap(0x0,29032448,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34608996352 (0x80edb6000)
munmap(0x80d20a000,29016064)			 = 0 (0x0)
mmap(0x0,29048832,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638028800 (0x810966000)
munmap(0x80edb6000,29032448)			 = 0 (0x0)
mmap(0x0,29065216,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810966000,29048832)			 = 0 (0x0)
mmap(0x0,29081600,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609045504 (0x80edc2000)
munmap(0x80d20a000,29065216)			 = 0 (0x0)
read(9,"en Cuba}\t\t1978\n"Estudio 1" (1"...,65536) = 65536 (0x10000)
mmap(0x0,29097984,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638127104 (0x81097e000)
munmap(0x80edc2000,29081600)			 = 0 (0x0)
mmap(0x0,29114368,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x81097e000,29097984)			 = 0 (0x0)
mmap(0x0,29130752,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609094656 (0x80edce000)
munmap(0x80d20a000,29114368)			 = 0 (0x0)
mmap(0x0,29147136,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638225408 (0x810996000)
munmap(0x80edce000,29130752)			 = 0 (0x0)
read(9,"07\n"Eterna Magia" (2007) {(2007"...,65536) = 65536 (0x10000)
mmap(0x0,29163520,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810996000,29147136)			 = 0 (0x0)
mmap(0x0,29179904,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609143808 (0x80edda000)
munmap(0x80d20a000,29163520)			 = 0 (0x0)
mmap(0x0,29196288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638323712 (0x8109ae000)
munmap(0x80edda000,29179904)			 = 0 (0x0)
mmap(0x0,29212672,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x8109ae000,29196288)			 = 0 (0x0)
read(9,")}\t1991\n"Eva y Ad\M-an, agenci"...,65536) = 65536 (0x10000)
mmap(0x0,29229056,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609192960 (0x80ede6000)
munmap(0x80d20a000,29212672)			 = 0 (0x0)
mmap(0x0,29245440,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638422016 (0x8109c6000)
munmap(0x80ede6000,29229056)			 = 0 (0x0)
mmap(0x0,29261824,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x8109c6000,29245440)			 = 0 (0x0)
mmap(0x0,29278208,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609242112 (0x80edf2000)
munmap(0x80d20a000,29261824)			 = 0 (0x0)
read(9,"A. (#9.4)}\t2004\n"Everybody Lov"...,65536) = 65536 (0x10000)
mmap(0x0,29294592,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638520320 (0x8109de000)
munmap(0x80edf2000,29278208)			 = 0 (0x0)
mmap(0x0,29310976,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x8109de000,29294592)			 = 0 (0x0)
mmap(0x0,29327360,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609291264 (0x80edfe000)
munmap(0x80d20a000,29310976)			 = 0 (0x0)
mmap(0x0,29343744,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638618624 (0x8109f6000)
munmap(0x80edfe000,29327360)			 = 0 (0x0)
read(9,"\t\t1988\n"Everyman" (1977) {Who"...,65536) = 65536 (0x10000)
mmap(0x0,29360128,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x8109f6000,29343744)			 = 0 (0x0)
mmap(0x0,29376512,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609340416 (0x80ee0a000)
munmap(0x80d20a000,29360128)			 = 0 (0x0)
mmap(0x0,29392896,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638716928 (0x810a0e000)
munmap(0x80ee0a000,29376512)			 = 0 (0x0)
mmap(0x0,29409280,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810a0e000,29392896)			 = 0 (0x0)
read(9,"xclusive" (1997) {(#1.1)}\t\t\t"...,65536) = 65536 (0x10000)
mmap(0x0,29425664,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609389568 (0x80ee16000)
munmap(0x80d20a000,29409280)			 = 0 (0x0)
mmap(0x0,29442048,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638815232 (0x810a26000)
munmap(0x80ee16000,29425664)			 = 0 (0x0)
mmap(0x0,29458432,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810a26000,29442048)			 = 0 (0x0)
mmap(0x0,29474816,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609438720 (0x80ee22000)
munmap(0x80d20a000,29458432)			 = 0 (0x0)
read(9,"\n"Explorers: Adventures of the "...,65536) = 65536 (0x10000)
mmap(0x0,29491200,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34638913536 (0x810a3e000)
munmap(0x80ee22000,29474816)			 = 0 (0x0)
mmap(0x0,29507584,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810a3e000,29491200)			 = 0 (0x0)
mmap(0x0,29523968,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609487872 (0x80ee2e000)
munmap(0x80d20a000,29507584)			 = 0 (0x0)
mmap(0x0,29540352,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34639011840 (0x810a56000)
munmap(0x80ee2e000,29523968)			 = 0 (0x0)
read(9,"xtra" (1994) {(2011-05-03)}\t\t"...,65536) = 65536 (0x10000)
mmap(0x0,29556736,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34579980288 (0x80d20a000)
munmap(0x810a56000,29540352)			 = 0 (0x0)
mmap(0x0,29573120,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34609537024 (0x80ee3a000)
SIGNAL 14 (SIGALRM)
sigprocmask(SIG_SETMASK,SIGINT|SIGQUIT|SIGALRM|SIGCHLD|SIGIO|SIGPROF|SIGWINCH,0x0) = 0 (0x0)
sigreturn(0x7ffffffec630,0x7ffffffec630,0x301,0x0,0xfffffffffffffbc0,0x0) = 34609537064 (0x80ee3a028)
munmap(0x80d20a000,29556736)			 = 0 (0x0)
recvmsg(0x6,0x7ffffffecb80,0x0,0x1000,0x1c30000,0x0) ERR#35 'Resource temporarily unavailable'
--8<---------------cut here---------------end--------------->8---

And here's the version with the patch above applied.

  Should Emacs use the GNU version of malloc?             yes
  Should Emacs use a relocating allocator for buffers?    yes
  Should Emacs use mmap(2) for buffer allocation?         no

--8<---------------cut here---------------start------------->8---
sigprocmask(SIG_BLOCK,SIGINT|SIGALRM,0x0)	 = 0 (0x0)
clock_gettime(0,{1418846834.087766996 })	 = 0 (0x0)
ktimer_settime(0x3,0x1,0x7ffffffece90,0x0,0x0,0xd10fe8) = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,SIGINT|SIGALRM)	 = 0 (0x0)
nanosleep({0.000001000 })			 = 0 (0x0)
read(5,"n the Family" (1971) {Archie See"...,65536) = 65536 (0x10000)
break(0xeb9a000)				 = 0 (0x0)
read(5,"en" (1970) {(#1.5899)}\t\t\t1992"...,65536) = 65536 (0x10000)
break(0xebaa000)				 = 0 (0x0)
read(5,"\t\t2008\n"All My Children" (197"...,65536) = 65536 (0x10000)
break(0xebba000)				 = 0 (0x0)
read(5,"(1998) {False Convictions (#8.15"...,65536) = 65536 (0x10000)
break(0xebca000)				 = 0 (0x0)
read(5,"la lei\M-p" (2008) {Fimmti \M-~"...,65536) = 65536 (0x10000)
break(0xebda000)				 = 0 (0x0)
read(5,"014\n"Allt f\M-vr Sverige" (2011"...,65536) = 65536 (0x10000)
SIGNAL 14 (SIGALRM)
sigreturn(0x7ffffffeca70,0x10003,0x7ffffffeca70,0x7ffffffed478,0x41e8,0xd10fe8) = 25710504 (0x1884fa8)
recvmsg(0x4,0x7ffffffecbc0,0x0,0x1000,0x41e8,0xd10fe8) ERR#35 'Resource temporarily unavailable'
--8<---------------cut here---------------end--------------->8---