From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.bugs Subject: bug#19393: 25.0.50; Emacs cannot determine coding system of ISO-8859 encoded files Date: Tue, 13 Jan 2015 15:06:01 +0100 Message-ID: <85h9vuai48.fsf@iznogoud.viz> References: <87sigfpqmx.fsf@thinkpad-t440p.tsdh.org> <85oar3xwc1.fsf@iznogoud.viz> <871tnzs7y6.fsf@thinkpad-t440p.tsdh.org> <85mw6m4aqs.fsf@iznogoud.viz> <83zjamuvgf.fsf@gnu.org> <85egry464g.fsf@iznogoud.viz> <83y4q6us1v.fsf@gnu.org> <85bnn1pvr1.fsf@iznogoud.viz> <83388dudvt.fsf@gnu.org> <85vbl8nce4.fsf@iznogoud.viz> <83tx0suajy.fsf@gnu.org> <85vbl7qa3x.fsf@iznogoud.viz> <83ioh6srv8.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1421158476 32737 80.91.229.3 (13 Jan 2015 14:14:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Jan 2015 14:14:36 +0000 (UTC) Cc: 19393@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 13 15:14:29 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YB2El-0004ff-Gh for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Jan 2015 15:14:27 +0100 Original-Received: from localhost ([::1]:39444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB2Ek-0002Bf-TH for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Jan 2015 09:14:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB29d-0002bI-P3 for bug-gnu-emacs@gnu.org; Tue, 13 Jan 2015 09:09:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YB29W-0006H3-OF for bug-gnu-emacs@gnu.org; Tue, 13 Jan 2015 09:09:05 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB29W-0006Gv-LE for bug-gnu-emacs@gnu.org; Tue, 13 Jan 2015 09:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YB29W-00011B-7N for bug-gnu-emacs@gnu.org; Tue, 13 Jan 2015 09:09:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87sigfpqmx.fsf@thinkpad-t440p.tsdh.org> Resent-From: Wolfgang Jenkner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Jan 2015 14:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19393-submit@debbugs.gnu.org id=B19393.14211581003863 (code B ref 19393); Tue, 13 Jan 2015 14:09:02 +0000 Original-Received: (at 19393) by debbugs.gnu.org; 13 Jan 2015 14:08:20 +0000 Original-Received: from localhost ([127.0.0.1]:55129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YB28p-00010E-W1 for submit@debbugs.gnu.org; Tue, 13 Jan 2015 09:08:20 -0500 Original-Received: from b2bfep14.mx.upcmail.net ([62.179.121.59]:48407) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YB28m-0000zw-Fk for 19393@debbugs.gnu.org; Tue, 13 Jan 2015 09:08:18 -0500 Original-Received: from edge11.upcmail.net ([192.168.13.81]) by b2bfep14.mx.upcmail.net (InterMail vM.8.01.05.11 201-2260-151-128-20120928) with ESMTP id <20150113140809.EOEZ11972.b2bfep14-int.chello.at@edge11.upcmail.net> for <19393@debbugs.gnu.org>; Tue, 13 Jan 2015 15:08:09 +0100 Original-Received: from iznogoud.viz ([85.127.90.213]) by edge11.upcmail.net with edge id fS871p01G4cBfQ50BS88xl; Tue, 13 Jan 2015 15:08:09 +0100 X-SourceIP: 85.127.90.213 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.84 (FreeBSD)) (envelope-from ) id 1YB28d-0000Im-HR; Tue, 13 Jan 2015 15:08:07 +0100 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98291 Archived-At: --=-=-= Content-Type: text/plain Here's a simple change in src/buffer.c that reduces the time to six seconds or so, but only for newer versions of FreeBSD. It takes advantage of the MAP_EXCL flag for mmap(2), which has been recently added[1] and is also available in 10-STABLE and 10.1-RELEASE. In percentage of user CPU time, the hotuser script[2] from the dtrace toolkit shows a change from [...] emacs-25.0.50.1`decode_coding 537 0.1% emacs-25.0.50.1`produce_chars 2109 0.4% emacs-25.0.50.1`decode_coding_charset 2544 0.5% libc.so.7`memcpy 516884 98.9% to [...] libc.so.7`memcpy 220 4.1% bootstrap-emacs`decode_coding 488 9.0% bootstrap-emacs`produce_chars 2100 38.8% bootstrap-emacs`decode_coding_charset 2501 46.2% (the second column counts sample points, of which there are 1001 per second for each CPU core) The numbers are for the system compiler (clang 3.4.1) with default optimizations, though they are even a bit better for gcc 4.9. However, if the file in question is compressed revert-buffer-with-coding-system still takes 4 minutes (the user time being dominated to 98% by memmove). [1] https://svnweb.freebsd.org/base?view=revision&revision=267630 [2] https://svnweb.freebsd.org/base/stable/10/cddl/contrib/dtracetoolkit/hotuser?revision=256281&view=co --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Actually-use-mmap_enlarge-for-FreeBSD-10.1-or-newer.patch Content-Description: Use MAP_EXCL mmap flag. >From b0233ff2274e554339da3c4606ff7fb5fc961e82 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Tue, 23 Dec 2014 01:50:10 +0100 Subject: [PATCH] Actually use mmap_enlarge for FreeBSD 10.1 or newer. * src/buffer.c (MAP_EXCL): Make sure it is always defined. (MMAP_ALLOCATED_P, mmap_enlarge): Use it. This alleviates a performance problem due to excessive use of memcpy(3). (Bug#19393) --- src/ChangeLog | 8 ++++++++ src/buffer.c | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 252dfd3..b526e28 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2014-12-24 Wolfgang Jenkner + + Actually use mmap_enlarge for FreeBSD 10.1 or newer. + * buffer.c (MAP_EXCL): Make sure it is always defined. + (MMAP_ALLOCATED_P, mmap_enlarge): Use it. + This alleviates a performance problem due to excessive use of + memcpy(3). (Bug#19393) + 2015-01-12 Paul Eggert Port to 32-bit MingGW --with-wide-int diff --git a/src/buffer.c b/src/buffer.c index d0ffe67d9..8a97f3d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4683,10 +4683,19 @@ static bool mmap_initialized_p; Default is to conservatively assume the address range is occupied by something else. This can be overridden by system configuration - files if system-specific means to determine this exists. */ + files if system-specific means to determine this exists. + + However, if MAP_EXCL is defined assume that it is an mmap flag + which, combined with MAP_FIXED, has FreeBSD semantics, viz., the + mapping request will fail if a mapping already exists within the + range (the flag was first present in release 10.1). */ + +#ifndef MAP_EXCL +#define MAP_EXCL 0 +#endif #ifndef MMAP_ALLOCATED_P -#define MMAP_ALLOCATED_P(start, end) 1 +#define MMAP_ALLOCATED_P(start, end) (!MAP_EXCL) #endif /* Perform necessary initializations for the use of mmap. */ @@ -4770,7 +4779,7 @@ mmap_enlarge (struct mmap_region *r, int npages) void *p; p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); + MAP_ANON | MAP_EXCL | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); if (p == MAP_FAILED) ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */ else if (p != region_end) -- 2.2.1 --=-=-=--