Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Frozen" serialization format #199

Merged
merged 4 commits into from
Feb 25, 2019
Merged

Conversation

andreigudkov
Copy link
Member

Container data is stored in a format identical
to their C memory layout.
Instead of full deserialization, a lightweight readonly
view can be created atop of provided buffer.
This reduces amount of allocations and copying
and is suitable for creating readonly bitmaps from
memory mapped files.

  • Added new functions:
    roaring_bitmap_frozen_size_in_bytes()
    roaring_bitmap_frozen_serialize()
    roaring_bitmap_frozen_view()

  • copy_on_write was moved into more generic roaring_array_t.flags
    To modify copy_on_write behavior, new functions were added:
    roaring_bitmap_get_copy_on_write()
    roaring_bitmap_set_copy_on_write()

  • roaring_bitmap_free() now takes pointer to a constant bitmap

Container data is stored in a format identical
to their C memory layout.
Instead of full deserialization, a lightweight readonly
view can be created atop of provided buffer.
This reduces amount of allocations and copying
and is suitable for creating readonly bitmaps from
memory mapped files.

* Added new functions:
  roaring_bitmap_frozen_size_in_bytes()
  roaring_bitmap_frozen_serialize()
  roaring_bitmap_frozen_view()

* copy_on_write was moved into more generic roaring_array_t.flags
  To modify copy_on_write behavior, new functions were added:
  roaring_bitmap_get_copy_on_write()
  roaring_bitmap_set_copy_on_write()

* roaring_bitmap_free() now takes pointer to a constant bitmap
@lemire
Copy link
Member

lemire commented Feb 25, 2019

Fantastic. I consider that this is a satisfactory fix for #74

@lemire lemire merged commit 2e6783a into RoaringBitmap:master Feb 25, 2019
@PerpEternal
Copy link

PerpEternal commented Aug 31, 2023

@andreigudkov Hello, why roaring_bitmap_frozen_view input buf must align 32, would it still work if I remove this restriction?

if ((uintptr_t)buf % 32 != 0) {

@andreigudkov
Copy link
Member Author

@andreigudkov Hello, why roaring_bitmap_frozen_view input buf must align 32, would it still work if I remove this restriction?

if ((uintptr_t)buf % 32 != 0) {

If I recall everything correctly, then:

  1. All containers of the bitset type are located in the very beginning of the buffer
  2. Bitset container operations use AVX2 operations with load_mm256_load_si256 (not loadu). This requires that input is aligned by 32 bytes.

Probably things have changed since frozen format was introduced, and maybe this check is not required anymore.

@lemire
Copy link
Member

lemire commented Aug 31, 2023

Bitset container operations use AVX2 operations with load_mm256_load_si256 (not loadu). This requires that input is aligned by 32 bytes.

They do not, at least not currently.

@lemire
Copy link
Member

lemire commented Sep 1, 2023

@PerpEternal It would be possible to revisit the alignment requirement, but someone needs to review the code and make sure that it is safe to lift it, and to run tests. If you are interested, don't hesitate. Ideally, we would want unit tests to make sure that it all works out.

@andreigudkov
Copy link
Member Author

@lemire Are you sure that you do not depend on the alignment? I can see that currently on x64 the alignment is either 32 or 64 (when I created frozen format, it was always 32).

bitset->words = (uint64_t *)roaring_aligned_malloc(

@lemire
Copy link
Member

lemire commented Sep 11, 2023

Are you sure that you do not depend on the alignment?

I am sure of nothing. I only wrote that it could be revisited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants