Repository navigation
xls/jit: Make JitRuntime layout queries lock-free and avoid redundant mask ops. - #5534
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
… mask ops. `JitRuntime` previously guarded an internal `LLVMContext` and `LlvmTypeConverter` with an `absl::Mutex` on every `GetTypeByteSize`, `GetTypeAlignment`, `PackArgs`, `UnpackBuffer`, and `BlitValueToBuffer` call because querying composite struct layouts on `llvm::DataLayout` mutates its internal layout map. That lock serialized concurrent callers and recomputed nested tuple layouts repeatedly. Separately, `LlvmTypeConverter` emitted multi-instruction sign-extension sequences and redundant padding-mask `and` instructions on power-of-two bit widths that already match their LLVM integer container width. Extract immutable target alignment and endianness parameters into `TargetLayoutInfo` during JIT and AOT compilation (using the compiler's existing `LLVMContext`), emit `TargetLayoutProto` in `AotPackageEntrypointsProto` so AOT wrappers and proc runtimes instantiate `JitRuntime` directly from serialized layout metadata without a process-global cache or `DataLayout` parsing, and evaluate all layout queries, value blitting, and buffer unpacking lock-free with single-pass tuple offset advancement. Temporarily retain a deprecated `JitRuntime::data_layout()` accessor (`ABSL_DEPRECATED`) populated only by the `llvm::DataLayout` constructors (live JIT runtimes) for legacy JIT callers migrating off direct `llvm::DataLayout` inspection. Simplify `LlvmTypeConverter::AsSignedValue` to a shift pair and elide no-op `ClearPaddingBits` masks when the XLS bit width equals the LLVM integer width. PiperOrigin-RevId: 1028359539
This branch has not been deployed
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.
xls/jit: Make JitRuntime layout queries lock-free and avoid redundant mask ops.
JitRuntimepreviously guarded an internalLLVMContextandLlvmTypeConverterwith anabsl::Mutexon everyGetTypeByteSize,GetTypeAlignment,PackArgs,UnpackBuffer, andBlitValueToBuffercallbecause querying composite struct layouts on
llvm::DataLayoutmutates itsinternal layout map. That lock serialized concurrent callers and recomputed
nested tuple layouts repeatedly. Separately,
LlvmTypeConverteremittedmulti-instruction sign-extension sequences and redundant padding-mask
andinstructions on power-of-two bit widths that already match their LLVM integer
container width.
Extract immutable target alignment and endianness parameters into
TargetLayoutInfoduring JIT and AOT compilation (using the compiler's existingLLVMContext), emitTargetLayoutProtoinAotPackageEntrypointsProtoso AOTwrappers and proc runtimes instantiate
JitRuntimedirectly from serializedlayout metadata without a process-global cache or
DataLayoutparsing, andevaluate all layout queries, value blitting, and buffer unpacking lock-free with
single-pass tuple offset advancement. Temporarily retain a deprecated
JitRuntime::data_layout()accessor (ABSL_DEPRECATED) populated only by thellvm::DataLayoutconstructors (live JIT runtimes) for legacy JIT callersmigrating off direct
llvm::DataLayoutinspection. SimplifyLlvmTypeConverter::AsSignedValueto a shift pair and elide no-opClearPaddingBitsmasks when the XLS bit width equals the LLVM integer width.