-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[corefoundation] Cache kCFNull
to avoid native calls
#15146
Conversation
Calling `Dlfcn.GetIntPtr` is quite slow and doing for each element of an native array slows them down. **Before** ``` BenchmarkDotNet=v0.12.1, OS=macOS 12.3.1 (21E258) [Darwin 21.4.0] Apple M1 2.40GHz, 1 CPU, 8 logical and 8 physical cores .NET Core SDK= 6.0.100 [/usr/local/share/dotnet/sdk] [Host] : .NET Core 6.0 (CoreCLR 6.0.522.21309, CoreFX 6.0.522.21309), X64 RyuJIT Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=3 LaunchCount=1 WarmupCount=3 ``` | Method | Length | Mean | Error | StdDev | |-------------------- |------- |----------------:|--------------:|-------------:| | ArrayFromHandleFunc | 0 | 140.98 ns | 10.995 ns | 0.603 ns | | ArrayFromHandleFunc | 1 | 650.99 ns | 34.037 ns | 1.866 ns | | ArrayFromHandleFunc | 16 | 6,884.68 ns | 284.458 ns | 15.592 ns | | ArrayFromHandleFunc | 256 | 101,171.27 ns | 675.731 ns | 37.039 ns | | ArrayFromHandleFunc | 4096 | 1,634,001.93 ns | 55,113.362 ns | 3,020.949 ns | **After** ``` BenchmarkDotNet=v0.12.1, OS=macOS 12.3.1 (21E258) [Darwin 21.4.0] Apple M1 2.40GHz, 1 CPU, 8 logical and 8 physical cores .NET Core SDK= 6.0.100 [/usr/local/share/dotnet/sdk] [Host] : .NET Core 6.0 (CoreCLR 6.0.522.21309, CoreFX 6.0.522.21309), X64 RyuJIT Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=3 LaunchCount=1 WarmupCount=3 ``` | Method | Length | Mean | Error | StdDev | |-------------------- |------- |--------------:|-------------:|-----------:| | ArrayFromHandleFunc | 0 | 141.48 ns | 3.905 ns | 0.214 ns | | ArrayFromHandleFunc | 1 | 307.06 ns | 9.457 ns | 0.518 ns | | ArrayFromHandleFunc | 16 | 1,227.28 ns | 13.334 ns | 0.731 ns | | ArrayFromHandleFunc | 256 | 14,076.72 ns | 418.940 ns | 22.963 ns | | ArrayFromHandleFunc | 4096 | 251,251.85 ns | 7,341.339 ns | 402.404 ns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ it! Thanks a lot @spouliot!
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Noticed the UPDATE: Original description updated with |
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
📋 [PR Build] API Diff 📋API diff (for current PR)ℹ️ API Diff (from PR only) (please review changes) .NETXamarin vs .NETAPI diff (vs stable)✅ API Diff from stable .NETXamarin vs .NETGenerator diffℹ️ Generator Diff (please review changes) Pipeline on Agent XAMBOT-1023.Monterey |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌Tests failed on VSTS: simulator tests iOS. Test results4 tests failed, 144 tests passed.Failed tests
Pipeline on Agent XAMBOT-1043.Monterey' |
Test failures are unrelated (https://github.com/xamarin/maccore/issues/2558). |
Calling
Dlfcn.GetIntPtr
is quite slow and doing for each element ofan native array slows them down.
Before
After