1 Return-Path: <beheerder@tekenbeetziekten.nl>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 26878431FC9
\r
6 for <notmuch@notmuchmail.org>; Wed, 13 Feb 2013 07:33:33 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id BDQPRYiFdQSQ for <notmuch@notmuchmail.org>;
\r
16 Wed, 13 Feb 2013 07:33:29 -0800 (PST)
\r
17 Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id D1B5A431FC7
\r
21 for <notmuch@notmuchmail.org>; Wed, 13 Feb 2013 07:33:28 -0800 (PST)
\r
22 Received: (qmail 20161 invoked from network); 13 Feb 2013 16:33:27 +0100
\r
23 Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo)
\r
25 by srv047132.webreus.nl with SMTP; 13 Feb 2013 16:33:27 +0100
\r
26 From: Robert Mast <beheerder@tekenbeetziekten.nl>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR
\r
29 Date: Wed, 13 Feb 2013 16:32:57 +0100
\r
30 Message-Id: <1360769577-4861-1-git-send-email-beheerder@tekenbeetziekten.nl>
\r
31 X-Mailer: git-send-email 1.7.9.5
\r
32 In-Reply-To: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>
\r
33 References: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>
\r
34 Cc: Robert Mast <beheerder@tekenbeetziekten.nl>
\r
35 X-BeenThere: notmuch@notmuchmail.org
\r
36 X-Mailman-Version: 2.1.13
\r
38 List-Id: "Use and development of the notmuch mail system."
\r
39 <notmuch.notmuchmail.org>
\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
43 List-Post: <mailto:notmuch@notmuchmail.org>
\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
47 X-List-Received-Date: Wed, 13 Feb 2013 15:33:33 -0000
\r
49 Using char instead of int allows for simpler definitions of the
\r
50 DOCIDSET macros so the code is easier to understand and consistent with
\r
51 respect to memory-usage. Estimated reduction of memory-usage for
\r
52 bitmap about 8 times.
\r
56 Re-submission for comment-reasons.
\r
60 lib/query.cc | 10 +++++-----
\r
61 1 file changed, 5 insertions(+), 5 deletions(-)
\r
63 diff --git a/lib/query.cc b/lib/query.cc
\r
64 index e9c1a2d..7381a54 100644
\r
67 @@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages {
\r
68 } notmuch_mset_messages_t;
\r
70 struct _notmuch_doc_id_set {
\r
71 - unsigned int *bitmap;
\r
72 + unsigned char *bitmap;
\r
76 -#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))
\r
77 -#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))
\r
78 +#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT)
\r
79 +#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT)
\r
81 struct visible _notmuch_threads {
\r
82 notmuch_query_t *query;
\r
83 @@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx,
\r
86 unsigned int max = 0;
\r
87 - unsigned int *bitmap;
\r
88 + unsigned char *bitmap;
\r
90 for (unsigned int i = 0; i < arr->len; i++)
\r
91 max = MAX(max, g_array_index (arr, unsigned int, i));
\r
92 - bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));
\r
93 + bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);
\r