From: Robert Mast Date: Wed, 13 Feb 2013 15:11:43 +0000 (+0100) Subject: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR X-Git-Url: http://git.tremily.us/?p=notmuch-archives.git;a=commitdiff_plain;h=32ef378083a8ba9b6eadd1d652d759b63aa0ec23 [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR --- diff --git a/0d/90a9a42aa49e407bb33b3619b31e1dc444c133 b/0d/90a9a42aa49e407bb33b3619b31e1dc444c133 new file mode 100644 index 000000000..865c7c1a6 --- /dev/null +++ b/0d/90a9a42aa49e407bb33b3619b31e1dc444c133 @@ -0,0 +1,85 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 68FB7431FC9 + for ; Wed, 13 Feb 2013 07:12:09 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 0QYAOv8j0pAD for ; + Wed, 13 Feb 2013 07:12:06 -0800 (PST) +Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id EB707431FC7 + for ; Wed, 13 Feb 2013 07:12:05 -0800 (PST) +Received: (qmail 16021 invoked from network); 13 Feb 2013 16:12:04 +0100 +Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo) + (87.210.109.73) + by srv047132.webreus.nl with SMTP; 13 Feb 2013 16:12:04 +0100 +From: Robert Mast +To: notmuch@notmuchmail.org +Subject: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR +Date: Wed, 13 Feb 2013 16:11:43 +0100 +Message-Id: <1360768303-4228-1-git-send-email-beheerder@tekenbeetziekten.nl> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl> +References: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl> +Cc: Robert Mast +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 13 Feb 2013 15:12:09 -0000 + +diff --git a/lib/query.cc b/lib/query.cc +index e9c1a2d..7381a54 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages { + } notmuch_mset_messages_t; + + struct _notmuch_doc_id_set { +- unsigned int *bitmap; ++ unsigned char *bitmap; + unsigned int bound; + }; + +-#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int)) +-#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int)) ++#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT) ++#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT) + + struct visible _notmuch_threads { + notmuch_query_t *query; +@@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx, + GArray *arr) + { + unsigned int max = 0; +- unsigned int *bitmap; ++ unsigned char *bitmap; + + for (unsigned int i = 0; i < arr->len; i++) + max = MAX(max, g_array_index (arr, unsigned int, i)); +- bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap)); ++ bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1); + + if (bitmap == NULL) + return FALSE; +-- +1.7.9.5 +