[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-16 Thread David Bremner
Robert Mast  writes:

> Using char instead of int allows for simpler definitions of the
> DOCIDSET macros so the code is easier to understand and consistent with
> respect to memory-usage. Estimated reduction of memory-usage for
> bitmap about 8 times.

Pushed to master.

I did a bit of testing, and this yields about a 7% improvement in the
total memory allocated on the medium corpus (running
performance-tests/M00-new) and about a 3% speedup running the large
corpus.  These are definitely improvements worth having, but I think I
won't push it to the bug fix release, but rather wait for the next
regular release.

d




Re: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-16 Thread David Bremner
Robert Mast beheer...@tekenbeetziekten.nl writes:

 Using char instead of int allows for simpler definitions of the
 DOCIDSET macros so the code is easier to understand and consistent with
 respect to memory-usage. Estimated reduction of memory-usage for
 bitmap about 8 times.

Pushed to master.

I did a bit of testing, and this yields about a 7% improvement in the
total memory allocated on the medium corpus (running
performance-tests/M00-new) and about a 3% speedup running the large
corpus.  These are definitely improvements worth having, but I think I
won't push it to the bug fix release, but rather wait for the next
regular release.

d


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-13 Thread Robert Mast
Using char instead of int allows for simpler definitions of the
DOCIDSET macros so the code is easier to understand and consistent with
respect to memory-usage. Estimated reduction of memory-usage for
bitmap about 8 times.

---

Re-submission for comment-reasons.

---
---
 lib/query.cc |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

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



[english 100%] [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-13 Thread Robert Mast
Somehow my comments don't get through... I'll try it another way.

-Oorspronkelijk bericht-
Van: Robert Mast [mailto:beheerder at tekenbeetziekten.nl] 
Verzonden: woensdag 13 februari 2013 16:12
Aan: notmuch at notmuchmail.org
CC: Robert Mast
Onderwerp: [english 100%] [PATCH] bitmap:improve memory usage using CHAR_BITS 
and unsigned CHAR

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


. 



[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-13 Thread Robert Mast
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



[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-13 Thread Carl Worth
Robert Mast  writes:
> Re-submission for comment-reasons.

Very nicely done, Robert. Thanks.

-Carl (who's not quite merging patches again yet, but likely will be soon)

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-13 Thread Robert Mast
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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-11 Thread Robert Mast
A little bug-fix to learn how to contribute to nutmuch, this time a combined 
commit with git rebase to provide one patch from 15.1.
---
 lib/query.cc |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

2013-02-10 Thread Robert Mast
A little bug-fix to learn how to contribute to nutmuch, this time a combined 
commit with git rebase to provide one patch from 15.1.
---
 lib/query.cc |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

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