Skip to content

refactor: remove the rand runtime dependency and add common random bit function - #264

Merged
tisonkun merged 6 commits into
apache:mainfrom
jeffoodchain:feat/common_random_bit
Sep 2, 2026
Merged

refactor: remove the rand runtime dependency and add common random bit function#264
tisonkun merged 6 commits into
apache:mainfrom
jeffoodchain:feat/common_random_bit

Conversation

@jeffoodchain

@jeffoodchain jeffoodchain commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Remove the rand runtime dependency from the published datasketches crate and add our own random generator.

KLL and REQ only require a random boolean when choosing which half of a
compaction range to promote. This PR replaces those calls with a small,
crate-private random_bit() implementation backed by a thread-local
SplitMix64 generator.

Closes #203

Changes

  • add a crate-private, thread-local SplitMix64 random-bit generator
  • seed each thread's generator on first use through RandomState
  • use random_bit() for KLL and REQ compaction decisions
  • remove rand from the kll and req feature dependency lists
  • remove rand from the published library's normal dependencies
  • document the dependency change in the changelog

The workspace still uses rand for benchmarks, but downstream users of the
datasketches crate no longer pull it in.

Compatibility

This does not change the public API or serialization format.

KLL and REQ compaction remain randomized. The new generator only replaces the
source of the random coin used to select which items are promoted.

Testing

  • cargo x check
  • cargo x lint
  • cargo x test

@tisonkun tisonkun changed the title Refactor: remove the rand runtime dependency and add common random bit function refactor: remove the rand runtime dependency and add common random bit function Sep 2, 2026

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tisonkun
tisonkun enabled auto-merge (squash) September 2, 2026 13:51
@tisonkun
tisonkun merged commit 3db8a5f into apache:main Sep 2, 2026
10 checks passed
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.

missing common_random support in library

2 participants