Conversation
Metric sampling has required allocation-free, nosplit field lookup since 1c9ce54. The large-field optimization in 79b3802 replaces linear search with a Go map, whose runtime lookup can split the stack even when fieldMapper.lookupSingle is marked nosplit. Checkescape has missed this because map lookups are not explicit SSA calls. For large fields, sort retained field values with their declaration indices by pointer address and use a nosplit binary search. Keep declaration order, pointer identity, and lookup behavior when a FieldValue's string changes. Retain linear search for small fields. Pointer ordering uses the same nonmoving heap assumption as pipe lock ordering. Store the pointers in the constructor map so caller-local values escape to the nonmoving heap. The large-field lookup becomes O(log n). An ARM64 microbenchmark with 1,024 field values changes from about 6.7 to 12.5 ns/op, without allocating. Add the benchmark and extend existing field tests across the lookup threshold. Fix panic assertions that previously succeeded even when no panic occurred. Assisted-by: Codex
Contributor
Author
|
@EtiennePerot could you please TAL as the author of the commits mentioned in the description? I discovered this while investigating failures in #14502. |
Contributor
Author
|
@konstantin-s-bogom mind having a look here? |
Contributor
Author
|
@EtiennePerot could you please take a look? once this lands I will put up another PR to fix the gap in checkescape that admitted this use of maps under nosplit. |
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.
Metric sampling has required allocation-free, nosplit field lookup since 1c9ce54. The large-field optimization in 79b3802 replaces linear search with a Go map, whose runtime lookup can split the stack even when fieldMapper.lookupSingle is marked nosplit. Checkescape has missed this because map lookups are not explicit SSA calls.
For fields with more than 48 values, sort retained field values with their declaration indices by pointer address and use a nosplit binary search. This preserves declaration order, pointer identity, and lookup behavior when a FieldValue's string changes. Small fields retain linear search. Pointer ordering uses the same nonmoving heap assumption as pipe lock ordering; storing the pointers in the constructor map ensures caller-local values escape to the heap. The lookup uses a local search loop because slices.BinarySearchFunc can split the stack.
Large-field lookup becomes O(log n). An ARM64 microbenchmark with 1,024 field values changes from about 6.7 to 12.5 ns/op, without allocating. Add the benchmark and extend existing field tests across the lookup threshold, including declaration order, pointer identity, and mutation of the value's string. Fix panic assertions that previously succeeded even when no panic occurred.
This fixes the metric consumer before a separate checkescape change begins detecting runtime calls implicit in map operations.
Assisted-by: Codex