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