1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00
Commit Graph

37 Commits

Author SHA1 Message Date
Zdenek Kabelac
9eafd44734 gcc: use more zero length arrays
Define last array struct member with zero size.
2021-09-22 17:18:50 +02:00
Zdenek Kabelac
ff21723512 hash: replace hash with better function
Add Bob Jenkins hash function to get better working hash function,
which does genarate way less colisions (especially with similar
strings).

For a comparision also a kernel function used in DM kernel is include.
While it's better then our existing one, it's still far worse,
then Bob Jenkins hash.
2021-03-08 15:33:15 +01:00
Zdenek Kabelac
d602837b91 hash: speed up hash tables
Enhance hash perfomance by remembering the computed
hash value for the hashed node - this allows to speedup
lookup of nodes with the hash collision when
different keys map to the same masked hash value.

For the easier use 'num_slots' become 'mask_slots',
so we only add '1' in rare case of need of the original
num_slots value.

Also add statistic counters for hashes and print stats in
debug build (-DDEBUG) on hash wiping.
(so badly performing hash can be optimized.)
2021-03-08 15:33:15 +01:00
Zdenek Kabelac
84679d254f hash: use unsigned size
There is not much point in using 64bit hash size, since we hash
with way less bits anyway. So keep size 32bit.
2021-03-08 15:33:15 +01:00
Zdenek Kabelac
1ff1e86deb cleanup: better expressing passing key arg to _hash 2020-09-01 17:57:50 +02:00
Zdenek Kabelac
85e2c7e14d cov: explicitely ignore function result 2020-09-01 17:57:50 +02:00
Zdenek Kabelac
fd96f1014b gcc: zero-sized array to fexlible array C99
Switch remaining zero sized struct to flexible arrays to be C99
complient.

These simple rules should apply:

- The incomplete array type must be the last element within the structure.
- There cannot be an array of structures that contain a flexible array member.
- Structures that contain a flexible array member cannot be used as a member of another structure.
- The structure must contain at least one named member in addition to the flexible array member.

Although some of the code pieces should be still improved.
2020-09-01 17:57:50 +02:00
Zdenek Kabelac
deb5160181 list: use container_of
Reuse macro
2020-05-20 16:01:20 +02:00
Zdenek Kabelac
b3fa71fbd8 libdm: fix dm_list pointer arithmentic for new gcc 10 optimization 2020-03-05 17:38:55 +01:00
Zdenek Kabelac
18aa541ca2 configure: avoid repeative inclusion of configure.h
Since configure.h is a generated header and it's missing traditional
ifdefs preambule - it can be included & parsed multiple times.
Normally compiler is fine when defines have same value and there is
no warning - yet we don't need to parse this several times
and by adding -include  directive we can ensure every file
in the package is rightly compile with configure.h as the
first header file.
2018-12-21 19:19:50 +01:00
Zdenek Kabelac
0b19387dae headers: use configure.h as 1st. header
Ensure configure.h is always 1st. included header.
Maybe we could eventually introduce gcc -include option, but for now
this better uses dependency tracking.

Also move _REENTRANT and _GNU_SOURCE into configure.h so it
doesn't need to be present in various source files.
This ensures consistent compilation of headers like stdio.h since
it may produce different declaration.
2018-12-14 15:09:13 +01:00
Zdenek Kabelac
1aac59f82a gcc: avoid shadowing index
Some older headers were declaring 'index' so avoid its usage.
/usr/include/string.h:489: warning: shadowed declaration is here
2018-12-01 01:06:51 +01:00
Zdenek Kabelac
9238b972c5 cov: mark warning as expected one 2018-11-03 16:10:32 +01:00
Zdenek Kabelac
c7789daec0 cov: overflow before widen
Evaluate as 64bit arithmetic (instead of doing 32bit mults which can
in this case purely teoretically overflow).
2018-11-03 16:10:31 +01:00
Zdenek Kabelac
30b1b57506 cov: add at least ASSERT
Seems lot of code here can't handle failing allocation.
Meanwhile before bigger fix put in asserts in place.
2018-10-15 17:49:44 +02:00
Zdenek Kabelac
eed8715e1d cov: fix missing null allocation check 2018-10-15 17:49:44 +02:00
Joe Thornber
bb17302084 [radix-tree] tidy up _degrade_to_n48
Shouldn't be any functional changes.
2018-09-20 14:28:47 +01:00
Joe Thornber
ebd2d7773f [radix-tree] Fix bug in _degrade_to_n16
Values were getting shuffled
2018-09-20 14:20:16 +01:00
Joe Thornber
0ac7913c6a [radix-tree] Fix bug in _dump
Values in an n48 were not being printed in the correct order.
2018-09-20 14:18:57 +01:00
Joe Thornber
abe2210c26 [radix-tree] Add some extra checks to is_well_formed() 2018-09-20 14:18:10 +01:00
Joe Thornber
4d964133e2 [radix-tree] alternative radix-tree implementation.
Sacrifices performance for simplicity, meant only for verification of
the real adaptive implementation.
2018-09-11 13:12:07 +01:00
Joe Thornber
8b05f1f230 radix-tree: Fix bug in remove_prefix()
Accidental decrement of the nr entries when a n256 didn't have the
entry in the first place.
2018-08-20 15:23:40 +01:00
Joe Thornber
254e5c5d11 radix-tree: squash a pointer arithmetic warning 2018-06-21 17:41:56 +01:00
Joe Thornber
72e2e92f4c radix-tree: fix bug when erasing elts in remove_prefix
_erase_elt() now zeroes the last element of the array (ie. sets to
UNSET).  Previously remove() was doing this, but not remove_prefix().
2018-06-21 17:10:05 +01:00
Joe Thornber
40c1f7889f radix-tree: More debugging of remove
There's now a pretty printer called radix_tree_dump()

n4, n16, and n48 weren't UNSETting the last entry after
sliding values down.
2018-06-21 09:49:43 +01:00
Joe Thornber
20b9746c5d radix-tree: FIx various bugs to do with removal
Add radix_tree_is_well_formed() which does some sanity checking
of the tree.

Call the above a lot in the unit tests.

Fix revealed bugs.
2018-06-21 09:49:08 +01:00
Joe Thornber
61e67e51e1 device_mapper: move hash.[hc] to base/data-struct 2018-06-08 13:54:19 +01:00
Joe Thornber
88ae928ca3 base: Move list to base/data-struct 2018-06-08 11:24:18 +01:00
Joe Thornber
06c789eda1 radix-tree: fix some bugs in remove_prefix and iterate
These weren't working if the prefix key was part of a prefix_chain.
2018-05-30 14:21:27 +01:00
Joe Thornber
1924426ad1 radix-tree: radix_tree_iterate() 2018-05-29 17:58:58 +01:00
Joe Thornber
c2a8bbed3b radix-tree: radix_tree_remove_prefix() 2018-05-29 13:25:59 +01:00
Joe Thornber
9b41efae82 radix-tree: call the value dtr when removing an entry. 2018-05-29 11:23:36 +01:00
Joe Thornber
0181c77e3f Merge branch '2018-05-29-radix-tree-iterate' into 2018-05-23-radix-tree-remove 2018-05-29 11:04:32 +01:00
Joe Thornber
033df741e2 data-struct/radix-tree: pass the value dtr into create.
Rather than having to pass it into every method that removes items.
2018-05-29 11:03:10 +01:00
Joe Thornber
b7fd8ac8eb radix_tree: add remove method 2018-05-23 12:48:06 +01:00
Joe Thornber
30a4c7988e radix-tree: remove some unneccessary includes 2018-05-11 09:46:34 +01:00
Joe Thornber
576dd1fc41 radix-tree: First drop of radix tree.
An implementation of an adaptive radix tree.  Has the following nice
properties:

  - At least as fast as the hash table
  - Uses less memory
  - You don't need to give an expected size when you create
  - It scales nicely (ie. no large reallocations like the hash table).
  - You can iterate the keys in lexicographical order.

Only insert and lookup are implemented so far.  Plus there's a lot
more performance to come.
2018-05-11 06:10:01 +01:00