Skip to content

Skip parsing PropertyNames when empty Parameters#7960

Merged
Arkatufus merged 4 commits into
akkadotnet:devfrom
snakefoot:dev
Dec 17, 2025
Merged

Skip parsing PropertyNames when empty Parameters#7960
Arkatufus merged 4 commits into
akkadotnet:devfrom
snakefoot:dev

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

@snakefoot snakefoot commented Dec 7, 2025

Removed unnecessary casting to array, since it will automatically match IReadOnlyList<object>.

Curious why you also convert into FrozenDictionary (another allocation that hurt performance). Since a LogEvent is a very temporary object, that is thrown away. FrozenDictionary are "expensive" to create, because you plan to hold on to them.

#if NET8_0_OR_GREATER
// Use FrozenDictionary for optimal read performance on .NET 8+
return System.Collections.Frozen.FrozenDictionary.ToFrozenDictionary(dict);
#else
return dict;
#endif

I find it strange that when calling Akka's LogMessage.ToString() and using semantic logging, then Akka-Formatter explodes in your face (Because string.Format only handles positional parameters).

Also strange that Akka LogMessage only supports message-template-properties. I find message-template properties very organic and error-prone (case-sensitive, spelling, etc.) compared to explicit "building" the LogEvent.

@Aaronontheweb
Copy link
Copy Markdown
Member

Curious why you also convert into FrozenDictionary (another allocation that hurt performance). Since a LogEvent is a very temporary object, that is thrown away. FrozenDictionary are "expensive" to create, because you plan to hold on to them.

We can totally get rid of that, especially because right now we don't even target .NET 8 so that compiler directive never gets hit. We're probably going to go straight to .NET 10 for v1.6.

I find it strange that when calling Akka's LogMessage.ToString() and using semantic logging, then Akka-Formatter explodes in your face (Because string.Format only handles positional parameters).

That's probably a bug that our test suite doesn't hit because rendering isn't done via that method, but rather through the template extraction system.

@Aaronontheweb
Copy link
Copy Markdown
Member

Appreciate the PR @snakefoot - happy to accept more for some of the other suggestions you have RE: the semantic logger. That's new code so there's probably room for improvement in there.

@Arkatufus
Copy link
Copy Markdown
Contributor

Curious why you also convert into FrozenDictionary (another allocation that hurt performance). Since a LogEvent is a very temporary object, that is thrown away. FrozenDictionary are "expensive" to create, because you plan to hold on to them.

The FrozenDictionary is practically dead code because we're not even targetting .NET 8.0

Copy link
Copy Markdown
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Arkatufus Arkatufus enabled auto-merge (squash) December 17, 2025 08:28
@Arkatufus Arkatufus merged commit cce6583 into akkadotnet:dev Dec 17, 2025
11 checks passed
@snakefoot
Copy link
Copy Markdown
Contributor Author

Notice your last-minute code-simplify reverts the optimization. Have created #7968 to redo the optimization.

Arkatufus added a commit to Arkatufus/akka.net that referenced this pull request Jan 7, 2026
* Skip parsing PropertyNames when not Parameters

* Simplify code

---------

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
Aaronontheweb pushed a commit that referenced this pull request Jan 8, 2026
* Skip parsing PropertyNames when not Parameters

* Simplify code

---------

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
This was referenced May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants