Widen 16-bit object counts before absl::bit_width in CentralFreeList. - #719
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
Widen 16-bit object counts before absl::bit_width in CentralFreeList.#719copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
CentralFreeList::RemoveRange and ReleaseToSpans index the span-utilization histogram by absl::bit_width of the per-span allocated-object count, which is a uint16_t. The uint16_t overload of absl::bit_width dispatches to CountLeadingZeroes16, which emulates a 16-bit count-leading-zeros with extra shifts and masks on top of the native 32-bit clz/lzcnt instruction. Widen the count to uint32_t before calling absl::bit_width so codegen emits a single native clz/lzcnt; the resulting bit_width values and histogram bucket indices are unchanged. The rewrite is confined to the non-legacy locking path (TCMALLOC_INTERNAL_LEGACY_LOCKING), leaving the legacy path byte-for-byte identical. PiperOrigin-RevId: 979950772
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Widen 16-bit object counts before absl::bit_width in CentralFreeList.
CentralFreeList::RemoveRange and ReleaseToSpans index the span-utilization
histogram by absl::bit_width of the per-span allocated-object count, which is a
uint16_t. The uint16_t overload of absl::bit_width dispatches to
CountLeadingZeroes16, which emulates a 16-bit count-leading-zeros with extra
shifts and masks on top of the native 32-bit clz/lzcnt instruction. Widen the
count to uint32_t before calling absl::bit_width so codegen emits a single
native clz/lzcnt; the resulting bit_width values and histogram bucket indices
are unchanged.
The rewrite is confined to the non-legacy locking path
(TCMALLOC_INTERNAL_LEGACY_LOCKING), leaving the legacy path byte-for-byte
identical.