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

feat: Make use of the last bit in Tid #107

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ldm0
Copy link

@ldm0 ldm0 commented Jan 3, 2025

Previously Tid::LEN was set to MAX_SHARDS.trailing_zeros() + 1, and MAX_SHARDS was set to next_pow2(Self::MAX_THREADS - 1), which leads to several odd conbinations:


MAX_THREADS=128
MAX_SHARDS=128
Tid::LEN=8

7 bit is enough to encode 128 threads, as the thread id starts from 0
and ends with Tid::BITS, which makes the extra one bit redundant(I can't find the usage of it).


MAX_THREADS=129
MAX_SHARDS=128
Tid::LEN=8

As shards are indexed by Tid, number of shards shouldn't be less than number of threads.


Therefore, I changed the implementation:

  • Tid::LEN now equals to MAX_SHARDS.trailing_zeros()
  • MAX_SHARDS now equals to next_pow2(Self::MAX_THREADS)
  • DefaultConfig::MAX_THREADS were doubled leveraging the released bit

Doubles the `MAX_THREADS` of `DefaultConfig`
@ldm0 ldm0 force-pushed the ldm_tid_squeeze branch 2 times, most recently from cc8c2f8 to b07966e Compare January 3, 2025 07:59
@ldm0
Copy link
Author

ldm0 commented Jan 3, 2025

Took a fierce fight with Rust 1.42 😅

@ldm0 ldm0 force-pushed the ldm_tid_squeeze branch from b07966e to 0468cb0 Compare January 3, 2025 08:51
@ldm0
Copy link
Author

ldm0 commented Jan 24, 2025

@hawkw Hi, could you review this?

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.

1 participant