-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve notification filter performance #15610
Conversation
@lahma I deleted |
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 know it's a closed PR, just adding couple thoughts...
// This is necessary as long as there will be string-based comparisons | ||
// and the need of NotifyEntryComparer | ||
|
||
var cache = _cache; |
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 guess nothing here prevents from Message changing and cache being invalid, private setter for properties (or being get-only) would make a different in API promises
@@ -175,7 +179,7 @@ private string SerializeNotifyEntry(NotifyEntry[] notifyEntries) | |||
try | |||
{ | |||
var protector = _dataProtectionProvider.CreateProtector(nameof(NotifyFilter)); | |||
var signed = protector.Protect(JConvert.SerializeObject(notifyEntries, _settings)); |
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.
Commenting here as I cannot comment on existing code...
_existingEntries = messageEntries.Concat(_existingEntries).Distinct(new NotifyEntryComparer(_htmlEncoder)).ToArray();
Have I ever told that I don't like LINQ 😉 Could probably use HashSet directly and also ideally if possible, NotifyEntryComparer.Default
(internal static readonly) if the serializer reference equals some known default, maybe internal NotifyEntryComparer.Create()
could check such a thing and either create a new instance or use a default one
After the move to STJ some metrics went up. This fixed the lock contentions and large object heaps. Plus some other GC stats are also better. The creation of
JsonSerializerOption
uses a weak reference and locks internally so they shouldn't be created too often. TheNotifyFilter
was created then eagerly while not necessary. Now it's only on demand with some extra caching.