-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Implement new SmallCapacityDictionary for dictionaries with a small amount of values. #31360
Conversation
f00ecc2
to
a4b53f5
Compare
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
9876c48
to
2733b31
Compare
Going to avoid the struct portion of this change in this PR for now (correctness issues in some down stack signalr tests). Will revisit in the future. |
Hm, I wonder if we could add a mode that make it so setting doesn't check if the item exists before. All sets need to check all values before inserting, may some sort of unsafe thing could be useful. |
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.
Looked at perf again. On my machine (win-x64) it shows improvements.
Some additional notes:
-
Dictionary<TKey, TValue> special cases type string, and uses a
NonRandomizedStringEqualityComparer
. Should this be done here too? -
if AdaptiveCapacityDictionary should be used for value types too, one could use of JIT's ability to devirtualize
EqualityComparer<TValue>.Default
and get nice perf-boost. Note: for shared generics (like string keys) this won't happen right now.
/// <param name="comparer">Equality comparison.</param> | ||
public AdaptiveCapacityDictionary(int capacity, IEqualityComparer<TKey> comparer) | ||
{ | ||
if (comparer is not null && comparer != EqualityComparer<TKey>.Default) // first check for null to avoid forcing default comparer instantiation unnecessarily |
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.
if (comparer is not null && comparer != EqualityComparer<TKey>.Default) // first check for null to avoid forcing default comparer instantiation unnecessarily | |
if (comparer is not null) |
If it's the default comparer it's assigned anyway, so this branch can be simplified?
[Benchmark] | ||
public void OneValue_SmallDict_Get() | ||
{ | ||
_smallCapDict.TryGetValue("test", out _); |
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.
These benchmarks should return a value to prevent dead-code optimization / to be on the safe side.
_dictionaryStorage![key] = value; | ||
return; |
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.
_dictionaryStorage![key] = value; | |
return; | |
_dictionaryStorage![key] = value; |
public int Count | ||
{ | ||
get | ||
{ | ||
if (_dictionaryStorage != null) | ||
{ | ||
return _dictionaryStorage.Count; | ||
} | ||
return _count; | ||
} | ||
} |
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.
A matter of taste:
public int Count | |
{ | |
get | |
{ | |
if (_dictionaryStorage != null) | |
{ | |
return _dictionaryStorage.Count; | |
} | |
return _count; | |
} | |
} | |
public int Count => _dictionaryStorage != null ? _dictionaryStorage.Count : _count; |
public IEqualityComparer<TKey> Comparer | ||
{ | ||
get | ||
{ | ||
return _comparer ?? EqualityComparer<TKey>.Default; | ||
} | ||
} |
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.
public IEqualityComparer<TKey> Comparer | |
{ | |
get | |
{ | |
return _comparer ?? EqualityComparer<TKey>.Default; | |
} | |
} | |
public IEqualityComparer<TKey> Comparer => _comparer; |
_comparer
won't be null, every ctor-path assigns a value.
private bool ContainsKeyArray(TKey key) | ||
{ | ||
Debug.Assert(_dictionaryStorage == null); | ||
Debug.Assert(_arrayStorage != null); | ||
|
||
var array = _arrayStorage; | ||
var count = _count; | ||
|
||
if ((uint)count <= (uint)array.Length) | ||
{ | ||
for (var i = 0; i < count; i++) | ||
{ | ||
if (_comparer.Equals(array[i].Key, key)) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} |
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.
private bool ContainsKeyArray(TKey key) | |
{ | |
Debug.Assert(_dictionaryStorage == null); | |
Debug.Assert(_arrayStorage != null); | |
var array = _arrayStorage; | |
var count = _count; | |
if ((uint)count <= (uint)array.Length) | |
{ | |
for (var i = 0; i < count; i++) | |
{ | |
if (_comparer.Equals(array[i].Key, key)) | |
{ | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
private bool ContainsKeyArray(TKey key) => TryFindItem(key, out _); |
I verifyed the codegen and perf. Looks good that way, as the JIT eliminates the dead unnecessary code due to inlining.
if (_dictionaryStorage != null) | ||
{ | ||
return _dictionaryStorage.ContainsKey(key); | ||
} | ||
|
||
return ContainsKeyCore(key); |
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.
Here I'd be more aggressive and prioritize the small sizes.
if (_dictionaryStorage != null) | |
{ | |
return _dictionaryStorage.ContainsKey(key); | |
} | |
return ContainsKeyCore(key); | |
if (_dictionaryStorage is null) | |
{ | |
return ContainsKeyArray(key); | |
} | |
return _dictionaryStorage.ContainsKey(key); |
For codegen the small sizes are in the hot-path, whilst the fallback is moved down to a colder region.
Additional the cpu's branch predictor prefers the fall-through path when there's not history.
In the micro-benchmarks this effect won't show up, as the branch predictor has history and the I-caches are hot. The benefit should be in real-world usage -- but honestly, it's mini.
The method itself will inline, so aggressive-inline isn't necessary, but you can add if you want. I don't know...
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private bool ContainsKeyCore(TKey key) | ||
{ | ||
return ContainsKeyArray(key); |
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.
Should the logic for ContainsKeyArray
go here or remove ContainsKeyCore
?
It's just about putting less work to the JIT and it's inliner (budget). Contains
will inline in the code-path I checked, but with a deeper call-hierarchy this might hit JIT's inlining limit (I don't know the current limit from top of my head).
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private int FindIndex(TKey key) | ||
{ | ||
// Generally the bounds checking here will be elided by the JIT because this will be called |
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.
This comment is outdated, and maybe not true either.
E.g. Remove
calls this method, but doesn't call EnsureCapacity
.
var array = _arrayStorage; | ||
var count = _count; | ||
|
||
for (var i = 0; i < count; i++) | ||
{ | ||
if (_comparer.Equals(array[i].Key, key)) | ||
{ | ||
return i; | ||
} | ||
} |
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.
Same ways as TryFindItem
:
var array = _arrayStorage; | |
var count = _count; | |
for (var i = 0; i < count; i++) | |
{ | |
if (_comparer.Equals(array[i].Key, key)) | |
{ | |
return i; | |
} | |
} | |
if (_count > 0) | |
{ | |
for (var i = 0; i < ArrayStorageSpan.Length; ++i) | |
{ | |
if (_comparer.Equals(ArrayStorageSpan[i].Key, key)) | |
{ | |
return i; | |
} | |
} | |
} |
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.
I'd want to find at least one more consumer to verify the functionality before merging it.
Care to help me find one? What do you think of QueryCollection? https://github.com/dotnet/aspnetcore/blob/main/src/Http/Http/src/QueryCollection.cs |
|
Yes, that's an interesting candidate. |
Let's do a separate PR. Worst case, it fails in the next PR and we revert/fix parts of this. |
* Update dependencies from https://github.com/dotnet/efcore build 20210315.3 (dotnet#30960) [main] Update dependencies from dotnet/efcore * Feedback from Pranav * Remove regex use in DataProtection (dotnet#30855) * Fix null ref in SyntaxTokenCache (dotnet#30978) Fixes dotnet#27154 * Pool SocketSenders (dotnet#30771) - SocketAsyncEventArgs have lots of state on them and as a result are quite big (~350) bytes at runtime. We can pool these since sends are usually very fast and we can reduce the per connection overhead as a result. - We also allocate one per IOQueue to reduce contention. - Fixed buffer list management - Disposed pool when the transport is disposed - Added project to slnf so running tests in VS was possible - Clear the buffer and buffer list before returning to the pool - This cleans up dumps as the pooled senders don't see references to buffers while pooled in the queue - Keep track of items in the pool separately from the queue count. * Add Consolidated view classifier to make view types internal (dotnet#30976) * Add Consolidated view classifier to make view types internal * Address feedback from peer review * Address feedback and fix tests * Fix nullability of TypeNameHelper.GetTypeDisplayName parameter (dotnet#30987) * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#30968) [main] Update dependencies from dotnet/runtime dotnet/efcore - Remove assemblies from the ref and runtime pack - Remove more references * Update src/Features/JsonPatch/src/Internal/ConversionResultProvider.cs Co-authored-by: Pranav K <prkrishn@hotmail.com> * Update src/Features/JsonPatch/src/PublicAPI.Unshipped.txt Co-authored-by: Pranav K <prkrishn@hotmail.com> * Update dependencies from https://github.com/dotnet/efcore build 20210316.2 (dotnet#30991) [main] Update dependencies from dotnet/efcore * HTTP/3 input validation and connection abort (dotnet#29665) * Connection error for invalid HTTP/3 frame on request stream * Update src/Servers/Kestrel/Core/src/CoreStrings.resx * Write frame types and errors codes in logs as per spec * Clean up * Add HTTP/3 connection exception with code * Connection abort * More abort connection stuff * More test * More tests * PR feedback * Update dependencies from https://github.com/dotnet/efcore build 20210317.1 (dotnet#30998) [main] Update dependencies from dotnet/efcore * helix + pw + linux/osx (dotnet#30676) * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#30999) [main] Update dependencies from dotnet/runtime dotnet/efcore * Dispose streams that don't fit in pool (dotnet#30995) * Dispose streams that don't fit in pool * PR feedback * Update NodeJS dependency in build instructions (dotnet#31000) * Respect consolidated views in all document classifiers (dotnet#31008) * Respect consolidated views in all document classifiers * Address feedback from peer review * E2E test apps for WinForms and WPF BlazorWebView (dotnet#31021) * Add API to Renderer to trigger a UI refresh on hot reload (dotnet#30884) * Add API to Renderer to trigger a UI refresh on hot reload Fixes dotnet#30816 * Update RazorExtensions.cs (dotnet#31029) * Fix credscan issues in aspnetcore (dotnet#30337) * Fix credscan issues in DataProtection * Fix credscan issues in Identity, except where they affect checked in certs * Updated scan * [Blazor] Adds static web assets support for Blazor desktop (dotnet#31041) * Wires up static web assets support on the WebViewManager. * Support ElementReference.Focus in WebView (dotnet#31050) * Support InputFile in WebView (dotnet#31049) * Update DotNetMuxerTest (dotnet#31053) Fixes dotnet#24082 * Bring back working DevServer packaging setup (dotnet#31043) * Bring pack working DevServer packaging setup * Revert "Bring pack working DevServer packaging setup" This reverts commit 0dda92e. * Update runtimeconfig.template.json * Quarantine one failing test (dotnet#31045) - dotnet#31044 - `RazorPagesTemplate_RazorRuntimeCompilation_BuildsAndPublishes()` * Update SDK to bring unified assembly changes (dotnet#31039) * Update SDK to bring unified assembly changes * Update SDK to pick up Razor pages fix * Fixup test Co-authored-by: Pranav K <prkrishn@hotmail.com> * Update launchSettings to indicate hotReload is to be used (dotnet#31060) * Fix race in FrameAfterTrailers_UnexpectedFrameError dotnet#30754 (dotnet#31061) * Fix JS interop cases in WebView (dotnet#31054) * Template tests: Create dev cert only once (dotnet#31012) * Simplify Razor bug reports. (dotnet#31033) * Simplify Razor bug reports. - We now have better mechanisms for capturing information so no need to scare users off. * Address code review feedback * [Blazor][Desktop] Mark packages as shipping (dotnet#31035) * Make packages shipping * Update RepoTasks to msbuild 16.9 * Update global.json * Update Nuget * Remove WebView dependency to AspNetCore.App (dotnet#31071) The Blazor Desktop project must not depend on Microsoft.AspNetCore.App because it needs to run on almost any platform, including Android/iOS. But AspNetCore.App doesn't run on those platforms. This changes WebView to not use any packages that are part of AspNetCore.App, such as StaticFiles and Http.Abstractions. Instead, it has copies of those files. * Use longer delay in test (dotnet#31072) * [SignalR TS] Fix permanent Disconnecting state (dotnet#30948) * Changed logLevel to Information instead of warning for EphemeralDataProtectionProvider (dotnet#29405) Fixes dotnet#29107 * [Blazor][Desktop] Fixes nullable annotations on the public API baselines (dotnet#31073) * Fix nullable annotations * Fix APIs * Add missing API baseline file * Implements shadow copying for ASP.NET Core + IIS (dotnet#28357) * Suppress generating source checksums when configured (dotnet#31089) Hot reload / EnC does not like it when type level attributes are modified. Razor views and Pages include a RazorSourceChecksumAttribute that includes a checksum of all of it's inputs (current cshtml file, and all _ViewImports that contribute to it). It's used used by runtime compilation to tell if the compiled view is current compared to it's inputs. However, it gets in the way with enc since editing a file updates the checksum. We'll disable this feature by default in RazorSourceGenerator, and enable it using an MSBuild switch that's configured by runtime compilation * Caching Redis: Add option to register profiling session (dotnet#31018) * Add option to register profiling session * Add API change * Fix public API declaration * Cleanup * Quarantine and fix RequestTrailers_CanReadTrailersFromRequest dotnet#31057 (dotnet#31059) * Sync shared code from runtime (dotnet#31094) Co-authored-by: Tratcher <Tratcher@users.noreply.github.com> * Revert "Remove ANCM shim and outofprocess handler from Runtime SiteEx… (dotnet#31042) * Revert "Remove ANCM shim and outofprocess handler from Runtime SiteExtension (dotnet#24884)" This reverts commit 7f7528f. * Enable site extension build temporarily * Enable build native * Fixing site extension build * No need to set * Fixing up build * Update .azure/pipelines/ci.yml * Update ci.yml * retry * Update .azure/pipelines/ci.yml * Follow ups for Blazor AOT (dotnet#31098) * Follow ups for Blazor AOT * Add Emscripten packs to manifest * Update acquire tool to use manifest from the dotnet sdk * Add AOT option to templates * Undo Emscripten for now * [Blazor] [Desktop] Exclude Resources.resx from the embedded file manifest (dotnet#31107) Excludes unnecessary embedded resources from the embedded files manifest provider. * Fix some low hanging allocation fruit (dotnet#31115) * Fix some low hanging allocation fruit - Use singleton pipe options - Use Task.Yield instead of AwaitableThreadPool on the server side - Change WebSocketMiddleware handshake helpers to remove enumerator allocations. * Fix issues preventing hot reload for Blazor WASM (dotnet#31108) * Configure DOTNET_MODIFIABLE_ASSEMBLIES=debug env variable * Fixup broken reflection * Fixup targeting pack intermediate zip version * Add new Polly DI extension method for HttpClientFactory (dotnet#28283) * Fix IDE warnings Fix IDE warnings about non-disposed handlers. * Update return type documentation Update the comment's type to match the method's. * Add new AddPolicyRegistry overload Add a new overload for AddPolicyRegistry() that allows the caller to configure the policy registry using other services that are registered with the service provider, such as config. * Add more nullability to Mvc.Core (dotnet#31076) * Update nuget & msbuild versions (dotnet#31064) * Update nuget & msbuild versions * Update RepoTasks.csproj * Fix one test * Fix all tests * Update dependencies from https://github.com/dotnet/arcade build 20210317.3 (dotnet#31124) Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk From Version 6.0.0-beta.21160.7 -> To Version 6.0.0-beta.21167.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update branding to 6.0.0-preview4 * Revert "Update branding to 6.0.0-preview4" This reverts commit 5c8e9f1. * Added missing event ids for hosting events (dotnet#31149) - Fixed slnf file * Don't separately build arm64 installers * Don't build targeting pack nupkgs * Undo change that stopped building installers in win-arm64 leg. This reverts commit 03aab5d. * Update comment * Update branding to 6.0.0-preview4 (dotnet#31153) * Dispose the DiagnosticListener (dotnet#31170) - Add the DiagnosticListener to the DI container as a lambda so it gets disposed. * Add support for tabs vs. spaces settings for generated files * Fixed grammar on `SessionOptions.IOTimeout` XML (dotnet#31174) Fixed grammar on `SessionOptions.IOTimeout` * Resolve remaining credscan bugs (dotnet#31157) * Default to Kestrel over IISExpress (dotnet#31161) * Update CONTRIBUTING.md (dotnet#31167) * Update CONTRIBUTING.md * Follow-up edits * Add tracing to templates process launch for debugging (dotnet#31202) * Add tests * Cleanup * Cleanup * Remove unsafe from BytesOrdinalEqualsStringAndAscii (dotnet#31201) * Add field * Cleanup * Revert changes to global.json * fix naming * Add hotReloadProfile to Razor Pages template (dotnet#31197) * BlazorTemplate test improvements (dotnet#30907) * Split the HPackEncoder partial class (dotnet#31210) * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#31020) [main] Update dependencies from dotnet/runtime dotnet/efcore - Do not declare iOS and Android support everywhere - runtime update includes new annotations making non-support obvious - see dotnet/runtime#49354 (w/ a similar Android PR coming soon) - !fixup! Fix typo in item group name - !fixup! Set `$(RemoveDevicePlatformSupport)` in correct project - not needed in BlazorManifest.csproj - but, is needed in dotnet-install-blazoraot.csproj - suppress - Fixup * Annotate Blazor wasm auth assemblies for trimmability (dotnet#31119) Minor cleanup when inspecting the code * Creates script command for sql-cache-tool (dotnet#30398) * Creates script command for sql-cache-tool * Includes idempotency, output to stdout, or specific file * Fixes help suggestion to be command-specific * Corrects typo * Revert "BlazorTemplate test improvements (dotnet#30907)" (dotnet#31223) This reverts commit 730e39b. * Sync shared code from runtime (dotnet#31182) Co-authored-by: dotnet <dotnet@users.noreply.github.com> * Unquarantine BootResourceCachingTest (dotnet#31154) * Resolve final credscan bug (dotnet#31196) * READMEs for Servers (dotnet#31207) * READMEs for Servers * Remove en-us * Update src/Servers/README.md Co-authored-by: Brennan <brecon@microsoft.com> * Update src/Servers/Kestrel/README.md Co-authored-by: Chris Ross <Tratcher@Outlook.com> * Update src/Servers/IIS/README.md Co-authored-by: Chris Ross <Tratcher@Outlook.com> * Feedback * Update src/Servers/HttpSys/README.md * Quick test * HttpSys * Update README.md * Feedback * Update src/Servers/IIS/README.md Co-authored-by: Günther Foidl <gue@korporal.at> * Update src/Servers/Kestrel/README.md Co-authored-by: Günther Foidl <gue@korporal.at> Co-authored-by: Brennan <brecon@microsoft.com> Co-authored-by: Chris Ross <Tratcher@Outlook.com> Co-authored-by: Günther Foidl <gue@korporal.at> * Components test parole for good behavior (dotnet#31156) * Add hotReloadProfile to Razor Pages template (dotnet#31216) * Add hotReloadProfile to Razor Pages template * Turn off hotReloadProfile for Blazor WebAssembly projects The WebAssembly experience is a bit problematic in preview3 because of runtime issues dotnet/runtime#50190. We'll turn it off in the templates by default to avoid giving a confusing experience out of the box. * [main] Update dependencies from dotnet/efcore dotnet/runtime (dotnet#31220) [main] Update dependencies from dotnet/efcore dotnet/runtime * Readmes for HTTP and Site Extensions (dotnet#31250) * Readmes for HTTP and Site Extensions * Apply suggestions from code review Co-authored-by: Brennan <brecon@microsoft.com> Co-authored-by: Brennan <brecon@microsoft.com> * Update dependencies from https://github.com/dotnet/efcore build 20210325.2 (dotnet#31254) [main] Update dependencies from dotnet/efcore * Refactor and fix failing tests * Revert global.json changes * Enable CA2012 (Use ValueTask Correctly) (dotnet#31221) * Unquarantine a couple servers tests (dotnet#31213) * Update src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriter.cs Co-authored-by: Pranav K <prkrishn@hotmail.com> * Sync shared code from runtime (dotnet#31271) Co-authored-by: Tratcher <Tratcher@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20210326.1 (dotnet#31277) [main] Update dependencies from dotnet/runtime * Use Emscripten SDKs in WASM workload (dotnet#31259) * Update dependencies from https://github.com/dotnet/efcore build 20210326.1 (dotnet#31283) [main] Update dependencies from dotnet/efcore * Clean up verbiage on build scripts (dotnet#31262) * Clean up verbiage on build scripts * Update docs/BuildFromSource.md Co-authored-by: Kevin Pilch <kevinpi@microsoft.com> Co-authored-by: Kevin Pilch <kevinpi@microsoft.com> * Enable nullable on more authentication projects (dotnet#31230) * Enable nullable on Azure projects (dotnet#31298) * Reduce allocations for Cookies. (dotnet#31258) * Update dependencies from https://github.com/dotnet/efcore build 20210326.2 (dotnet#31292) [main] Update dependencies from dotnet/efcore * [release/6.0-preview3] Update dependencies from dotnet/efcore dotnet/runtime (dotnet#31255) [release/6.0-preview3] Update dependencies from dotnet/efcore dotnet/runtime - Port changes from main - Merge branch 'release/6.0-preview3' into darc-release/6.0-preview3-ce4fb228-ea32-4f60-95e1-0e60d42e3fc3 * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#31310) [main] Update dependencies from dotnet/runtime dotnet/efcore * Update dependencies from https://github.com/dotnet/runtime build 20210327.4 (dotnet#31329) [main] Update dependencies from dotnet/runtime * Fix comment grammar (dotnet#31326) Minor update to XML docs to fix sentence grammar. * Use LoggerMessage.Define in HttpSys (dotnet#31333) - Use LoggerMessage.Define() throughout HttpSys instead of ILogger extension methods. - Also updates two incorrect event Id field names. Fixes dotnet#31313. * Reduce the per connection overhead in SocketConnection (dotnet#31308) * Reduce the per connection overhead in SocketConnection - Removed 3 state machines (StartAsync, ProcessSends and ProcessReceives) - Use ValueTask to remove delegate allocation on both senders and receivers - Remove field from DoSend and DoReceive state machine * Faster strongly typed features for server FeatureCollection (dotnet#31322) - Use strongly typed features - Use Unsafe.As to workaround dotnet/runtime#49614 - Do the casting it for Set<T> as well - Add more benchmarks - Reorder features (order of reset); * Update dependencies from https://github.com/dotnet/runtime build 20210328.6 (dotnet#31350) [main] Update dependencies from dotnet/runtime * Move logging to separate class to prevent allocation per generic type (dotnet#31345) * Badges, badges! (Licence, Help wanted, Good first issue, Chat) (dotnet#31341) * Badges, badges! (Licence, Help wanted, Good first issue, Chat) * Use correct links * Update dependencies from https://github.com/dotnet/efcore build 20210329.1 (dotnet#31351) [main] Update dependencies from dotnet/efcore * Fix WebView header APIs and behavior (dotnet#31246) * Fix WebView header APIs and behavior - Change WebView to return dictionary of headers instead of strings (this is needed for Android) - Change StaticContentProvider to use filename (always exists) instead of physical file path (not always available) to determine MIME type - Fix WPF sample bug * Update dependencies from https://github.com/dotnet/efcore build 20210329.2 (dotnet#31352) [main] Update dependencies from dotnet/efcore * Update dependencies from https://github.com/dotnet/efcore build 20210327.1 (dotnet#31309) [release/6.0-preview3] Update dependencies from dotnet/efcore * Update dependencies from https://github.com/dotnet/runtime build 20210329.3 (dotnet#31363) [release/6.0-preview3] Update dependencies from dotnet/runtime * Refactor logging in generic classes (dotnet#31364) * Update dependencies from https://github.com/dotnet/efcore build 20210329.4 (dotnet#31366) [release/6.0-preview3] Update dependencies from dotnet/efcore * Update dependencies from https://github.com/dotnet/efcore build 20210329.3 (dotnet#31353) [main] Update dependencies from dotnet/efcore * Make RequestDelegateFactory public (was MapActionExpressionTreeBuilder) (dotnet#31171) * Make RequestDelegateBuilder public - Formerly known as MapActionExpressionTreeBuilder * Add new BuildRequestDelegate overloads * Address PR feedback * RequestDelegateBuilder -> RequestDelegateFactory * Build -> Create * Address final review feedback. * [Http] Remove some unsafe code and save a string allocation (dotnet#31267) * Use one shot pbkdf2 (dotnet#31200) * Use one shot pbkdf2 * Update NetCorePbkdf2Provider.cs * CR feedback * CR feedback * Fix * Just use GetBytes for now * Update NetCorePbkdf2Provider.cs * Use interned Header Names for known headers not in the pre-allocated block (dotnet#31311) * Use interned headernames for known headers not in the preallocated block * Switch Connection header values for interned values * Use interned strings for websockets * Keep baggage, tracestate, and traceparent with previous casing * Update src/Servers/Kestrel/shared/KnownHeaders.cs Co-authored-by: Chris Ross <Tratcher@Outlook.com> * Feedback Co-authored-by: Chris Ross <Tratcher@Outlook.com> * Revert global.json changes * Modify constructor * Remove IReceiveHotReloadContext and HotReloadContext (dotnet#31281) * Remove IReceiveHotReloadContext and HotReloadContext React to API review feedback. Substitute IReceiveHotReloadContext and HotReloadContext with RenderHandle.IsHotReloading * Fixup * Update src/Components/Components/src/RenderHandle.cs * Update src/Components/Components/src/Properties/ILLink.Substitutions.xml * Update src/Components/Components/src/Properties/ILLink.Substitutions.xml * Flow Kestrel CancellationTokens to BindAsync (dotnet#31377) * Update dependencies from https://github.com/dotnet/runtime build 20210329.5 (dotnet#31384) [main] Update dependencies from dotnet/runtime * [main] Update dependencies from dotnet/arcade (dotnet#31349) [main] Update dependencies from dotnet/arcade * Quarantine flaky test (dotnet#31389) * Clean up NetCore PBKDF2 provider. (dotnet#31391) * Update dependencies from https://github.com/dotnet/runtime build 20210330.7 (dotnet#31394) [release/6.0-preview3] Update dependencies from dotnet/runtime * Add a FeaturesCollection constructor that supports initial capacity (dotnet#31381) * Add a FeaturesCollection constructor that supports initial capacity * Raise authenticationFailed event when cert validation fails (dotnet#31370) * Unquarantine UseStartupFactoryWorks (dotnet#31297) * Update dependencies from https://github.com/dotnet/efcore build 20210330.1 (dotnet#31400) [release/6.0-preview3] Update dependencies from dotnet/efcore * Update dependencies from https://github.com/dotnet/efcore build 20210330.2 (dotnet#31401) [main] Update dependencies from dotnet/efcore * Fix generated CSS scopes in layout views and update templates (dotnet#31257) * Fix generated CSS scopes in layout views and update templates * Update template baselines * Enabled scoped CSS for MVC template tests * Bring back static CSS file * Quarantine ClosesAfterDataSent (dotnet#31405) * Update CONTRIBUTING.md (dotnet#31371) Removed tab that seemed to cause a paragraph about the new help wanted label to be in a code fence. * Support round trip serialization of AuthenticationProperties with System.Text.Json (dotnet#31330) dotnet#20722 * Update Microsoft.Net.Compilers.Toolset (dotnet#31403) * Improve test failures for unexpected logs (dotnet#31406) * Add ToString() to Testing's log WriteContext * Update StrictTestServerTests to only show unexpected log * Undo template change that induced flakiness (dotnet#31417) * Add helpful exception message when exception handler returns 404 (dotnet#31142) * Update dependencies from https://github.com/dotnet/runtime build 20210331.6 (dotnet#31421) [release/6.0-preview3] Update dependencies from dotnet/runtime * Do not serialize Parameters property on AuthenticationProperties (dotnet#31414) * Do not serialize Parameters Explicitly prevent the Parameters dictionary from being included in the deserialized payload. See dotnet#31330 (comment). * Ignore props backed by Items Also ignore the properties backed by the Items dictionary to minimise the size of the serialized JSON payload. * Add ignoreLineEndingDifferences Stop tests from failing on non-Windows OSs due to different line endings. * ArPow stage 1: local source-build infrastructure (dotnet#31235) Conflicts: eng/Version.Details.xml Co-authored-by: John Luo <johluo@microsoft.com> * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#31411) [main] Update dependencies from dotnet/runtime dotnet/efcore * Update dependencies from https://github.com/dotnet/efcore build 20210331.4 (dotnet#31424) [release/6.0-preview3] Update dependencies from dotnet/efcore * Fix project path in slnf (dotnet#31431) * Fix trailing comma in Caching.slnf (dotnet#31438) * Fix file headers in src/Caching (dotnet#31439) * [SignalR Java] Update to RxJava3 (dotnet#31426) * Fixed de-duping hosting startup assemblies (dotnet#31440) - De-dupe hosting startup assemblies based on assembly instance not the name of the assembly. Names can be short or long and we don't know if they resolve to the same assembly. Instead of trying to mess with names, we just check to make sure that the instance isn't the same. * Trim down framework references for Blazor dev server (dotnet#31420) * Only include Microsoft.AspNetCore.App framework reference for Blazor dev server * Address feedback from peer review * Use SharedFxVersion property * Cross-target last few projects to DefaultNetCoreTargetFramework (dotnet#31239) * Cross-target last 2 projects to DefaultNetCoreTargetFramework * More projects * Fixup * Fixup again * Fixup * Undo SiteExtension change * Update src/SiteExtensions/LoggingBranch/LB.csproj Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> * [main] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#31425) [main] Update dependencies from dotnet/runtime dotnet/efcore * Use integer division trick to get exact base64 length (dotnet#31442) * Add nullability to more MVC assemblies (dotnet#31338) * Add nullability to more MVC assemblies * [x] MVC.Cors * [x] Mvc.DataAnnotations * [x] Mvc.Localization * [x] Mvc.Newtonsoft.Json * [ ] Mvc.ViewFeatures (partial) * Fixup * Update src/Mvc/Mvc.ViewFeatures/src/Rendering/ViewContext.cs * Apply suggestions from code review * Update RazorPagePropertyActivator.cs * Update assembly check on EventHandlerTagHelperDescriptorProvider (dotnet#31458) * Remove legacy routing (dotnet#31295) * [release/6.0-preview3] Update dependencies from dotnet/runtime dotnet/efcore (dotnet#31451) [release/6.0-preview3] Update dependencies from dotnet/runtime dotnet/efcore * Update dependencies from https://github.com/dotnet/arcade build 20210331.6 (dotnet#31427) [main] Update dependencies from dotnet/arcade - Merge branch 'main' into darc-main-2c400715-e553-48d8-8d43-983dc7aa4b7d * Update dependencies from https://github.com/dotnet/efcore build 20210401.3 (dotnet#31468) [main] Update dependencies from dotnet/efcore * Fix project paths in Azure.slnf (dotnet#31435) * Fix project paths in Azure.slnf * Update Azure.slnf * Update IdentityModel versions to 6.10.0 dotnet#31454 (dotnet#31482) * Removed static activity source from hosting (dotnet#31483) * Removed static activity source from hosting - Get it from DI instead * Fixed test * Use Random.Shared property (dotnet#31453) * Use Random.Shared Use the new .NET 6 Random.Shared static property where possible. See dotnet/runtime#50297. * Revert WebApi-CSharp changes For some reason I don't understand, this template doesn't see Random.Shared when compiled so this reverts the previous change for this template. * Remove baseline suppressions from 5.0 (dotnet#29934) * Remove baseline suppressions from 5.0 * Use newer NuGet.Protocol version - v4.8.2 ➡️ v5.8.1 * Fix condition * Back to 5.8.1 * Undo components changes * Whoops * Whoops Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> * Remove DNT from pre-reserved headers (dotnet#31493) No modern browser uses it anymore * Reuse HttpProtocol CTS (dotnet#31466) * Change Router _emptyParametersDictionary to a regular Dictionary (dotnet#31460) * Change Router _emptyParametersDictionary to a regular Dictionary This allows for ReadOnlyDictionary to be trimmed in a default Blazor WASM app. Saving roughly 3 KB .br compressed. Contributes to dotnet#30098 * Update src/Components/Components/src/Routing/Router.cs Co-authored-by: James Newton-King <james@newtonking.com> * Clean up some MVC code (dotnet#31511) * Clean up some MVC code * PR feedback * Do not throwing on InputBase.Dispose() if not in EditContext. (dotnet#31510) * Do not throwing on InputBase.Dispose() if not in EditContext. Fixes dotnet#30990 * Cache filters between requests in the ordinary case (dotnet#31513) In the normal case, * only the DefaultFilterFactoryProvider is registered * all filters registered by the framework are reusable We could so something targeted and cache filter instances between requests. * Update dependencies from https://github.com/dotnet/arcade build 20210403.1 (dotnet#31526) [main] Update dependencies from dotnet/arcade * Flaky tests (dotnet#31502) * Revert "Update assembly check on EventHandlerTagHelperDescriptorProvider (dotnet#31458)" (dotnet#31530) This reverts commit 7bc87ba. * Ability to deactivate DataAnnotationsValidation dynamically. Fixes dotnet#31027 (dotnet#31413) * Use UriHelper.BuildAbsolute for RedirectToHttpsRule (dotnet#28899) * Use UriHelper.BuildAbsolute and UriHelper.BuildRelative for RedirectRule (dotnet#28903) * Still send 100 Continue with null MinRequestBodyDataRate (dotnet#31543) * Update Selenium/Playwright (dotnet#31497) * Update Selenium/Playwright * Update selenium-config.json * Update Versions.props * Added VSCode debugging (for MvcSandbox) & code analysis support (dotnet#29486) * Added VSCode debugging support for MvcSandbox * Added ignored vscode folders * 1. Convered some more projects. 2. Added env variable for TargetFramework and used it in launch.json file rather than hardcoding TFW. * Addressed PR feedback. 1. Removed extensions.json 2. Updated BuildFromSource.md for Vscode instructions. 3. Added launch settings for BasicTestApp. * Addressed PR feedback! * Implement new SmallCapacityDictionary for dictionaries with a small amount of values. (dotnet#31360) * Fix duplicated event names in KestrelTrace logger. (dotnet#31523) (dotnet#31554) * Update area-owners.md (dotnet#31552) * Data Protection minor tidying (dotnet#31512) * Remove unused code Remove unused constant, method and variable. * Remove array allocations Use Array.Empty() instead of allocating an empty array. Use a static array for activation type instead of creating a new one per invocation. * Rename field Address PR feedback. * [SignalR TS] Improve connection error messages (dotnet#31402) * [MVC] Fix MSB4186 error (dotnet#31066) Fix MSB4186 error if a project references Microsoft.AspNetCore.Mvc.Testing that is not itself an ASP.NET project, such as a helper library in a test suite. * Re-use cancellation tokens in the https middleware (dotnet#31528) * Re-use cancellation tokens in the https middleware - These tokens are usually short lived and exist for the purposes of cancelling the handshake. * Fix IPNetwork.Contains behavior for prefixes which are not at start of subnet range (dotnet#31573) * Update branding to 5.0.6 (dotnet#31563) * Use skipEnabledCheck for LoggerMessage.Define (dotnet#31562) * Use skipEnabledCheck in MVC * Use skipEnabledCheck in Http/Routing DefaultLinkGenerator, DefaultLinkParser, and DfaMatcher * Use skipEnabledCheck in SignalR * Use skipEnabledCheck in Components * Use skipEnabledCheck in Hosting * Use skipEnabledCheck in Servers/HttpSys * Use skipEnabledCheck in Servers/Kestrel * Use skipEnabledCheck in Middleware * Avoid some allocations by checked IsEnabled first in MVC * Avoid some allocations by checked IsEnabled first in Servers/Kestrel * Simplify usage of logging in transports * Fix up typo in Blazor Server launchSettings.json (dotnet#31580) * Rename 'Blazor component' to 'component' to be more generic (dotnet#31590) Co-authored-by: Adrian Wright <adrian@compiledcoding.co.uk> * Update branding to 3.1.15 (dotnet#31577) * Update branding to 3.1.15 Update Ubuntu 16.04 to 18.04 * Remove obsolete groovy code * [release/5.0] Update nuget versions (dotnet#31490) * Update nuget/msbuild versions * Update nuget * Nuget only * Fix baseline, update to 5.8.1 * Undo test change * Update MetadataSerializerTest.cs * Set cab name for TargetingPack.wixproj (dotnet#30975) * Added IConnectionSocketFeature (dotnet#31588) - Removed the nullable from the Socket property as approved in API review - Make the IConnectionSocketFeature an additional feature instead of one implemented on the TransportConnection. - Added a test to verify it works * Fix null ref in SyntaxTokenCache (dotnet#30978) (dotnet#30988) Fixes dotnet#27154 * Still send 100 Continue with null MinRequestBodyDataRate (dotnet#31568) * [SignalR TS] Fix permanent Disconnecting state (dotnet#30948) (dotnet#31253) * Fix arguments order for call of HeartbeatSlow (dotnet#28698) (dotnet#31080) Co-authored-by: Roman Marusyk <Marusyk@users.noreply.github.com> * Quarantine one failing test (dotnet#31045) (dotnet#31296) - dotnet#31044 - `RazorPagesTemplate_RazorRuntimeCompilation_BuildsAndPublishes()` Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> * Fix merge * Fix merge * Update HubConnection.Reconnect.test.ts * Update default-build.yml * Error boundaries (dotnet#30874) * Remove unused ADAL dependency (dotnet#31484) * Remove unused dependency * Remove outdated AAD sample * Custom event args: support receiving IJSObjectReference (dotnet#31591) * Add failing E2E case * Implement fix * Add E2E test * Update src/Components/test/testassets/BasicTestApp/EventCustomArgsComponent.razor * Update suppressions * [SignalR TS] Set keep alive timer in receive loop (dotnet#31300) * Unskip some fixed E2E tests (dotnet#31614) * Fix "no event handler" in simultaneous blur+removal case (dotnet#31612) * [SPA] Introduces new approach for proxying the SPA templates (dotnet#31564) * A new package Microsoft.AspNetCore.SpaProxy has been added that is used by the templates to launch their development proxy via npm/yarn. * The SPA development proxy for each CLI now is the frontend for the application and proxies the requests to the backend which is the ASP.NET Core application. * At publish time the application assets are copied to the wwwroot. * SpaServices.Extensions has been removed from the templates since it is no longer needed. MapFallbackToFile("index.html") handles unknown requests and serves the SPA entry point. * The templates have been updated to keep using HTTPS with the SPA proxy configured to use the ASP.NET Core HTTPS development certificate via a new aspnetcore-https.js file that ships within the template. * The configuration for angular has been updated with a proxy.conf.js file to proxy requests to the backend. * The entry point for the application in development is now https://localhost:5002 when using https and http://localhost:5002 otherwise. * Infer default sources for parameters of minimal actions (dotnet#31603) This does a big chunk of dotnet#30248 while heavily refactoring the RequestDelegateFactory by splitting it out into a bunch of smaller methods. For part 2 of dotnet#30248, a "scalar value type that lives in the System namespace", I went with the alternative of "Something convention-based like the presence of a bool TryParse(string, out T) method" instead. This conventions work for types in any namespace including user-defined types. * Avoid closure caused by local function (dotnet#31641) * Avoid closure caused by local function - Made the local function static and passed state via parameters. * Remove form support from minimal APIs (dotnet#31646) * Remove form support from minimal APIs * Add * MapActionSample -> MinimalSample * Remove MapActionSample.csproj from Mvc.slnf * [Templates] Update the react template to use the CLI proxy (dotnet#31652) Updates the react template to use the http-proxy-middleware for handling the requests instead of the asp.net core proxy in the same way it's done for the Angular template. * [SignalR] Allocate HubCallerClients once per connection (dotnet#31661) * [main] Update dependencies from dotnet/emsdk dotnet/efcore dotnet/runtime (dotnet#31576) [main] Update dependencies from dotnet/emsdk dotnet/efcore dotnet/runtime - Add `RemoveDevicePlatformSupport` To `Microsoft.AspNetCore.Authentication.Negotiate.csproj` Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Andre Milbradt <andremi@microsoft.com> Co-authored-by: Andre Milbradt <onegoodsausage@users.noreply.github.com> Co-authored-by: Pranav K <prkrishn@hotmail.com> Co-authored-by: Hao Kung <HaoK@users.noreply.github.com> Co-authored-by: David Fowler <davidfowl@gmail.com> Co-authored-by: Safia Abdalla <safia@microsoft.com> Co-authored-by: Kristian Hellang <kristian@hellang.com> Co-authored-by: msftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com> Co-authored-by: James Newton-King <james@newtonking.com> Co-authored-by: Chris Ross <Tratcher@Outlook.com> Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com> Co-authored-by: Kevin Pilch <kevinpi@microsoft.com> Co-authored-by: Javier Calvarro Nelson <jacalvar@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: N. Taylor Mullen <nimullen@microsoft.com> Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> Co-authored-by: Brennan <brecon@microsoft.com> Co-authored-by: Shreyas Jejurkar <shreyasjejurkar123@live.com> Co-authored-by: Justin Kotalik <jukotali@microsoft.com> Co-authored-by: Gabriel Lucaci <gabriel.lucaci.dev@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tratcher <Tratcher@users.noreply.github.com> Co-authored-by: John Luo <johluo@microsoft.com> Co-authored-by: Martin Costello <martin@martincostello.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Allison Chou <allichou@microsoft.com> Co-authored-by: Anthony J <reapsprgm@gmail.com> Co-authored-by: Jonathan Berube <jdberube@gmail.com> Co-authored-by: dotnet <dotnet@users.noreply.github.com> Co-authored-by: Günther Foidl <gue@korporal.at> Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: Ben Adams <thundercat@illyriad.co.uk> Co-authored-by: Andrzej <andrzej.pindor@gmail.com> Co-authored-by: Stephen Halter <halter73@gmail.com> Co-authored-by: Kevin Jones <vcsjones@github.com> Co-authored-by: Marek Linka <mareklinka@users.noreply.github.com> Co-authored-by: Kevin Miller <scoundrel@gmail.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Youssef Victor <youssefvictor00@gmail.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com> Co-authored-by: fvoronin <fvoronin@gmail.com> Co-authored-by: Paulo Morgado <470455+paulomorgado@users.noreply.github.com> Co-authored-by: Tanay Parikh <TanayParikh@users.noreply.github.com> Co-authored-by: Adrian Wright <47532258+adrianwright109@users.noreply.github.com> Co-authored-by: Adrian Wright <adrian@compiledcoding.co.uk> Co-authored-by: Sébastien Ros <sebastienros@gmail.com> Co-authored-by: Roman Marusyk <Marusyk@users.noreply.github.com>
For #31290.
Implements SmallCapacityDictionary, which uses a list for entries up to a threshold of 4, then falls back to an inner dictionary (using the inner dictionary for everything else).
Perf results showing better performance for add/get and allocates much less by default.
Needs unit tests and to figure out where we want to put this.