[MultiIndex] Memory consumption of ordered indices
Hi, What's the memory consumption of ordered indices? Is it implemented as a linked list, so two pointers per element? In that case for a write-only data structure an external ptr vector would make more sense wouldn't it? -- Olaf
Olaf van der Spek
Hi,
What's the memory consumption of ordered indices? Is it implemented as a linked list, so two pointers per element?
The overhead (on most platforms) is three pointers per node (and index): http://stackoverflow.com/a/4208349/213114 Color is usually embedded into one of the pointers: http://bannalia.blogspot.com/2008/11/optimizing-red-black-tree-color-bits.ht...
In that case for a write-only data structure an external ptr vector would make more sense wouldn't it?
What's a "write-only" structure supposed to be useful for? Anyway, s sorted vector is definitely better in terms of memory consumption than a single-index multi_index_container. Joaquin M López Muñoz Telefónica
On Fri, Feb 20, 2015 at 3:01 PM, Joaquin M Lopez Munoz
Olaf van der Spek
writes: Hi,
What's the memory consumption of ordered indices? Is it implemented as a linked list, so two pointers per element?
The overhead (on most platforms) is three pointers per node (and index):
http://stackoverflow.com/a/4208349/213114
Color is usually embedded into one of the pointers:
http://bannalia.blogspot.com/2008/11/optimizing-red-black-tree-color-bits.ht...
And for sequenced?
In that case for a write-only data structure an external ptr vector would make more sense wouldn't it?
What's a "write-only" structure supposed to be useful for? Anyway, s sorted vector is definitely better in terms of memory consumption than a single-index multi_index_container.
The data structure is filled once (data read from DB) and then queried lots. Perhaps a flat_map would be better suited. -- Olaf
On February 20, 2015 4:59:07 PM EST, Olaf van der Spek
Olaf van der Spek
writes: In that case for a write-only data structure an external ptr vector would make more sense wouldn't it?
What's a "write-only" structure supposed to be useful for? Anyway, s sorted vector is definitely better in terms of memory consumption
On Fri, Feb 20, 2015 at 3:01 PM, Joaquin M Lopez Munoz
wrote: than a single-index multi_index_container.
The data structure is filled once (data read from DB) and then queried lots. Perhaps a flat_map would be better suited.
Perhaps you mean "write once" rather than "write only"? ___ Rob (Sent from my portable computation engine)
Olaf van der Spek
On Fri, Feb 20, 2015 at 3:01 PM, Joaquin M Lopez Munoz
wrote: The overhead (on most platforms) is three pointers per node (and index):
http://stackoverflow.com/a/4208349/213114
Color is usually embedded into one of the pointers:
http://bannalia.blogspot.com/2008/11/ optimizing-red-black-tree-color-bits.html
And for sequenced?
Two pointers per node.
[...]
What's a "write-only" structure supposed to be useful for? [...]
The data structure is filled once (data read from DB) and then queried lots.
I'd say "read only" is a more common name fo this usage pattern.
Perhaps a flat_map would be better suited.
If you only have one index, this is likely so --flat_map would give you the least memory overhead. Joaquín M López Muñoz Telefónica
participants (3)
-
Joaquin M Lopez Munoz
-
Olaf van der Spek
-
Rob Stewart