Skip to content

Widen 16-bit object counts before absl::bit_width in CentralFreeList. - #719

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_979950772
Draft

Widen 16-bit object counts before absl::bit_width in CentralFreeList.#719
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_979950772

Conversation

@copybara-service

Copy link
Copy Markdown

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.

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
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