From: Alexey Tourbin <at@altlinux.ru>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] rpm: rsyncable deflate vs LZMA
Date: Fri, 30 May 2008 03:23:31 +0400
Message-ID: <20080529232331.GS7996@solemn.turbinal> (raw)
In-Reply-To: <20080529215609.GA20209@wo.int.altlinux.org>
[-- Attachment #1: Type: text/plain, Size: 3223 bytes --]
On Fri, May 30, 2008 at 01:56:10AM +0400, Dmitry V. Levin wrote:
> On Fri, May 30, 2008 at 01:31:14AM +0400, Alexey Tourbin wrote:
> [...]
> > У меня есть идея. Для выбора точек синхронизации (gzflush) можно
> > использовать не только "слепой" rsync hint, но и cpio hint -- как
> > только мы видим cpio magic "070707", мы знаем, что через несколько
> > байтов будет mtime и потом пойдёт имя и содержимое файла. То есть
> > sync можно делать в месте окончания очередного cpio header.
>
> Это заметно снизит степень сжатия, когда в архиве много маленьких файлов?
Этим можно управлять, чтобы сознательно пропускать только "совсем
маленькие" файлы.
> > Правда, я не знаю, даст это что-нибудь в случае с маленькими файлами
> > или нет. Это может ничего не дать из-за того, что первые совпавшие
> > блоки в сжатом виде всё равно могут отличаться (из-за backreferences
> > в предыдущий блок).
>
> Могут или будут?
Если сделать как показано ниже, то для пакета man-pages (после повторной
пересборки) 'speedup 1.09' возрастает до 'speedup 1.19'. То есть эффект
от синхронизации сразу после cpio хедера есть, он заметный, но не
настолько большой, чтобы всё искупать.
--- rpmio.c- 2008-05-29 22:27:55 +0400
+++ rpmio.c 2008-05-30 03:08:32 +0400
@@ -2148,6 +2148,9 @@ struct rsync_state {
typedef struct rpmGZFILE_s {
gzFile *gz;
struct rsync_state rs;
+ uint32_t cs; /* cpio state */
+ uint32_t nb; /* bytes pending for sync */
+
} rpmGZFILE;
static /*@null@*/ FD_t gzdOpen(const char * path, const char * fmode)
@@ -2274,6 +2277,56 @@ bool rsync_next(struct rsync_state *s, u
return false;
}
+/* from ../lib/cpio.h */
+#define CPIO_NEWC_MAGIC "070701"
+#define PHYS_HDR_SIZE 110
+
+static inline
+bool sync_hint(rpmGZFILE *rpmgz, unsigned char c)
+{
+ /* sync only if at least nb_min bytes pending */
+ static const uint32_t nb_min = PHYS_HDR_SIZE + 1024;
+ rpmgz->nb++;
+ if (rpmgz->cs >= sizeof(CPIO_NEWC_MAGIC) - 1) {
+ /* cpio major progress, reset rsync */
+ rpmgz->rs.n = rpmgz->rs.sum = 0;
+ rpmgz->cs++;
+ if (rpmgz->cs >= PHYS_HDR_SIZE) {
+ /* sync after cpio header */
+ rpmgz->cs = 0;
+ if (rpmgz->nb >= nb_min) {
+ rpmgz->nb = 0;
+ fprintf(stderr, "SYNC cpio\n");
+ return true;
+ }
+ else {
+ fprintf(stderr, "SKIP cpio\n");
+ return false;
+ }
+ }
+ }
+ else if (CPIO_NEWC_MAGIC[rpmgz->cs] == c) {
+ /* cpio minor progress */
+ rpmgz->cs++;
+ }
+ else {
+ rpmgz->cs = 0;
+ }
+ if (rsync_next(&rpmgz->rs, c)) {
+ if (rpmgz->nb >= nb_min) {
+ rpmgz->nb = 0;
+ rpmgz->cs = 0;
+ fprintf(stderr, "SYNC rsync\n");
+ return true;
+ }
+ else {
+ fprintf(stderr, "SKIP rsync\n");
+ return false;
+ }
+ }
+ return false;
+}
+
static ssize_t
rsyncable_gzwrite(rpmGZFILE *rpmgz, const unsigned char *const buf, size_t len)
{
@@ -2283,7 +2336,7 @@ rsyncable_gzwrite(rpmGZFILE *rpmgz, cons
size_t i;
for (i = 0; i < len; i++) {
- if (rsync_next(&rpmgz->rs, buf[i])) {
+ if (sync_hint(rpmgz, buf[i])) {
size_t n = i + 1 - (begin - buf);
rc = gzwrite(rpmgz->gz, begin, n);
if (rc < 0)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-05-29 23:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-29 12:38 Alexey Tourbin
2008-05-29 13:28 ` Alexander Bokovoy
2008-05-29 16:50 ` Alexey Tourbin
2008-05-29 18:37 ` Dmitry V. Levin
2008-05-29 19:50 ` Alexey Tourbin
2008-05-29 20:13 ` Alexey Tourbin
2008-05-29 20:28 ` Led
2008-05-29 20:42 ` Alexey Tourbin
2008-05-29 20:16 ` Alexander Bokovoy
2008-05-29 21:31 ` Alexey Tourbin
2008-05-29 21:56 ` Dmitry V. Levin
2008-05-29 23:23 ` Alexey Tourbin [this message]
2008-05-30 21:31 ` Alexey Tourbin
2008-05-31 10:09 ` [devel] rsyncability test: openoffice Alexey Tourbin
2008-05-30 9:27 ` [devel] rpm: rsyncable deflate vs LZMA Alexey Tourbin
2008-05-30 8:21 ` Anton V. Boyarshinov
2008-05-30 11:28 ` Alexey Tourbin
2008-05-30 10:44 ` Anton Farygin
2008-05-30 12:07 ` Alexander Bokovoy
2008-05-30 15:03 ` Anton V. Boyarshinov
2008-05-30 15:09 ` Dmitry V. Levin
2008-05-30 15:17 ` Anton V. Boyarshinov
2008-05-30 15:25 ` Mikhail Gusarov
2008-05-30 15:32 ` Anton V. Boyarshinov
2008-05-30 15:37 ` Mikhail Gusarov
2008-06-01 12:06 ` Anton Farygin
2008-05-31 10:25 ` Alexey Tourbin
2008-05-31 16:59 ` Kirill A. Shutemov
2008-06-01 0:33 ` Alexey Tourbin
2008-06-01 13:07 ` Mikhail Gusarov
2008-06-01 18:08 ` [devel] [JT] fortunezilla :) Michael Shigorin
2008-06-02 1:44 ` Sergey Balbeko
2008-06-02 5:06 ` Mikhail Gusarov
2008-06-02 7:54 ` Alexey I. Froloff
2008-06-02 8:21 ` Michael Shigorin
2008-06-01 19:05 ` [devel] rpm: rsyncable deflate vs LZMA Alexey I. Froloff
2008-05-30 11:47 ` Anton V. Boyarshinov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080529232331.GS7996@solemn.turbinal \
--to=at@altlinux.ru \
--cc=devel@lists.altlinux.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
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git