unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: More (de)compress?
Date: Tue, 20 Aug 2013 12:19:35 +0400	[thread overview]
Message-ID: <52132697.4050000@yandex.ru> (raw)
In-Reply-To: <52124ACD.20502@cs.ucla.edu>

On 08/19/2013 08:41 PM, Paul Eggert wrote:

> * It can be faster to compress using an external program,
>    since the compression can be done in parallel.  Have you
>    timed your compression approach on a multicore platform,
>    and compared its real time to doing it with external
>    compression?  (Similarly for decompression, though I
>    expect there we won't find the external program faster.)
>    You might try "pigz" for compression, since it's multicore
>    internally.

It's faster because the buffer machinery is slower than external
compression program's input reader (at least, in case of gzip).
I tried to compress 959 small text files (~16Mb in total) with
'gzip *.txt' (0.67s), dired-compress-file (6.15s, but don't forget
about fork+exec overhead) and simple ad-hoc function using
compress-region and zlib method:

(defun compress-file (name method)
   (message "Compress %s" name)
   (let ((ext (cdr (assoc method '((zlib . "gz") (bzlib . "bz2") (lzma . "xz")))))
	(buffer (find-file-literally name)))
     (when (null ext) (error "Unsupported compression method '%S'" method))
     (save-excursion
       (set-buffer buffer)
       (compress-region method)
       (delete-file (buffer-file-name))
       (rename-buffer (concat (buffer-name) "." ext))
       (write-file (concat (buffer-file-name) "." ext))
       (kill-buffer))))

The latter version deliberately takes ~19s. Unfortunately internal
compression support can't replace calls to external programs, especially
in batch operations where we need to (de)compress multiple files at once.
But internal compression should have some advantages when we just need
to show the contents of compressed buffer (I didn't try to check this
yet, BTW).

> * There seems to be quite a bit of repetition in configure.ac
>    and in the C code -- each compression package does pretty
>    much the same thing with respect to allocating buffers,
>    saving point, etc.  Could this be factored out to simplify
>    the code and make it easier to add future compression
>    algorithms?

Yes.

> * bzlib_detect and lzm_detect mishandle the case where the
>    buffer gap is located very near the start of the buffer.

Argh, yes.

> * If the buffer contains random garbage,
>    (decompress-region nil 1 100000)
>    signals "Unsupported decompression method", which
>    isn't very clear.  It should signal something like
>    "Unknown compression format".
>
> * The functions compress-region and decompress-region
>    should be defined on all platforms, even those that
>    lack all compression libraries.  They'll simply return
>    nil on such platforms, since they can't compress or
>    decompress anything.  This simplifies the C code and
>    will simplify Lisp code too.

OK.

Dmitry




  parent reply	other threads:[~2013-08-20  8:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 12:17 More (de)compress? Dmitry Antipov
2013-08-19 16:13 ` Eli Zaretskii
2013-08-19 16:28   ` Lars Magne Ingebrigtsen
2013-08-19 16:41 ` Paul Eggert
2013-08-19 16:57   ` Eli Zaretskii
2013-08-20  8:19   ` Dmitry Antipov [this message]
2013-08-20 14:32     ` Stefan Monnier
2013-08-20 14:34     ` 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52132697.4050000@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).