JIT: Fix profiled memcmp specialization for inline candidates - #134437
Conversation
Try length specialization before inline-candidate wrapping and clear candidate metadata only when a usable profile is selected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9c37cab-1590-4d11-a950-db4e7f065a3d
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
This comment was marked as outdated.
This comment was marked as outdated.
Match profiling to the lowering ISA limit rather than preferred vector width, and avoid specializing unsupported targets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9c37cab-1590-4d11-a950-db4e7f065a3d
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the fallback-threshold regression and add TieredPGO regression coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Resolved since last review (1)
|
@EgorBot -macos_arm -linux_amd -linux_arm using BenchmarkDotNet.Attributes;
public class Bench
{
private byte[] _bytes1 = null!;
private byte[] _bytes2 = null!;
[Params(1, 2, 5, 8, 16, 20, 32, 50, 64, 128)]
public int Length { get; set; }
[GlobalSetup]
public void Setup()
{
_bytes1 = new byte[Length];
_bytes2 = new byte[Length];
}
[Benchmark]
public bool Bytes() => _bytes1.AsSpan().SequenceEqual(_bytes2);
} |
|
PTAL @AndyAyersMS follow up to #134160 with improvements for SequenceEqual this time. |
|
I wonder how often this actually kicks in for realistic code. Do we have any benchmarks that run a mixture of lengths? Have you considered multi-guess for things like this? |
I expect it to be pretty common. It's basically what all string comparisons/startswith/endswith call under the hood. Because we can instrument inlined code now, this one actually manages to keep profile per call-site (acts as context-oriented). Basically, SequenceEqual is a work horse for all comparisons of arrays/spans of anything (blittable) |
|
/ba-g osx-arm64 stuck |

Since #134160 led to 69 benchmarks improved, I decided to do the same for memcmp idiom.
Benchmark
Results: EgorBot/Benchmarks#612 (arm64 only handles up to 32 bytes today).