Revert "libsepol: cache ebitmap cardinality value"
PATCH 1/1 Revert "libsepol: cache ebitmap cardinality value"
This reverts commit 542e878690ea1e310bed9adda6dcb28ca8cd1d53.
After 6968ea977501 ("libsepol: make ebitmap_cardinality() of linear complexity"), the caching only saves ~0.06 % of total semodule -BN running time (on x86_64 without using the POPCNT instruction), so it's no longer worth the added complexity.
--- libsepol/include/sepol/policydb/ebitmap.h | 1 - libsepol/src/ebitmap.c | 9 --------- 2 files changed, 10 deletions(-)
libsepol/include/sepol/policydb/ebitmap.h +0 -1
@@ -37,7 +37,6 @@ typedef struct ebitmap_node {typedef struct ebitmap {ebitmap_node_t *node;/* first node in the bitmap */ uint32_t highbit;/* highest position in the total bitmap */ -unsigned int cardinality;/* cached value of cardinality */ }ebitmap_t ;#define ebitmap_is_empty (e) (((e)->highbit) == 0)
libsepol/src/ebitmap.c +0 -9
@@ -67,7 +67,6 @@ int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1)ebitmap_destroy (dst); dst->node = tmp.node; dst->highbit = tmp.highbit; - dst->cardinality =0 ;return 0 ; }
@@ -131,13 +130,9 @@ unsigned int ebitmap_cardinality(ebitmap_t *e1)unsigned int count =0 ;ebitmap_node_t *n; -if (e1->cardinality || e1->highbit ==0 ) -return e1->cardinality; -for (n = e1->node; n; n = n->next) { count +=__builtin_popcountll (n->map); } - e1->cardinality = count;return count; }
@@ -201,7 +196,6 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src) } dst->highbit = src->highbit; - dst->cardinality = src->cardinality;return 0 ; }
@@ -317,7 +311,6 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value)free (n); } } - e->cardinality =0 ;/* invalidate cached cardinality */ return 0 ; } prev = n;
@@ -348,7 +341,6 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value) e->node = new; } - e->cardinality =0 ;/* invalidate cached cardinality */ return 0 ; }
@@ -368,7 +360,6 @@ void ebitmap_destroy(ebitmap_t * e) e->highbit =0 ; e->node =0 ; - e->cardinality =0 ;return ; }
Signature · 1 line
2.24.1
Quoted 9 lines · Ondrej Mosnacek
This reverts commit
542e878690ea1e310bed9adda6dcb28ca8cd1d53.After
6968ea977501("libsepol: makeebitmap_cardinality()of linear complexity"), the caching only saves ~0.06 % of total semodule -BN running time (onx86_64without using the POPCNT instruction), so it's no longer worth the added complexity.Signed-off-by Ondrej Mosnacek <[email protected]>
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Ondrej Mosnacek
This reverts commit
542e878690ea1e310bed9adda6dcb28ca8cd1d53.
Quoted 8 lines
Quoted 6 lines
After
6968ea977501("libsepol: makeebitmap_cardinality()of linear complexity"), the caching only saves ~0.06 % of total semodule -BN running time (onx86_64without using the POPCNT instruction), so it's no longer worth the added complexity.Signed-off-by Ondrej Mosnacek <[email protected]>Acked-by Stephen Smalley <[email protected]>
Applied.