Skip to content

Restrict sequence locks to multi-word flags and shrink mutation counts. - #2322

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

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

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Restrict sequence locks to multi-word flags and shrink mutation counts.

Any absl::Flag whose value fits in 8 bytes reads and writes its value atomically without consulting a sequence lock. Even so, every absl::flags_internal::FlagImpl in writable data previously paid 8 bytes for a sequence lock just to track modification counts for tests and flag savers.

Move SequenceLock into the multi-word flag value storage specialization so only types larger than 8 bytes allocate it. Track mutations on FlagImpl with a 3-bit saturating counter inside an atomic state byte that overflows into a process-wide map after seven updates, shrinking the base object from 72 bytes to 64 bytes and scalar flags from 80 bytes to 72 bytes.

@copybara-service copybara-service Bot changed the title Internal cleanup Restrict SequenceLock to >8 B FlagValue storage and track modifications with a 3-bit saturating counter. Oct 24, 2026
@copybara-service
copybara-service Bot force-pushed the test_1006216187 branch 9 times, most recently from 31776db to 39f0f66 Compare October 30, 2026 20:39
@copybara-service copybara-service Bot changed the title Restrict SequenceLock to >8 B FlagValue storage and track modifications with a 3-bit saturating counter. Restrict sequence locks to multi-word flags and shrink mutation counts. Oct 30, 2026
@copybara-service
copybara-service Bot force-pushed the test_1006216187 branch 2 times, most recently from 338cc7b to 943aeff Compare November 2, 2026 18:31
Any `absl::Flag` whose value fits in 8 bytes reads and writes its value atomically without consulting a sequence lock. Even so, every `absl::flags_internal::FlagImpl` in writable data previously paid 8 bytes for a sequence lock just to track modification counts for tests and flag savers.

Move `SequenceLock` into the multi-word flag value storage specialization so only types larger than 8 bytes allocate it. Track mutations on `FlagImpl` with a 3-bit saturating counter inside an atomic state byte that overflows into a process-wide map after seven updates, shrinking the base object from 72 bytes to 64 bytes and scalar flags from 80 bytes to 72 bytes.

PiperOrigin-RevId: 1006216187
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.

0 participants