Skip to content
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

LoggerMessageGenerator optimizations #91178

Open
Tracked by #97522
NinoFloris opened this issue Aug 27, 2023 · 1 comment
Open
Tracked by #97522

LoggerMessageGenerator optimizations #91178

NinoFloris opened this issue Aug 27, 2023 · 1 comment
Labels
area-Extensions-Logging source-generator Indicates an issue with a source generator feature
Milestone

Comments

@NinoFloris
Copy link
Contributor

Looking at a size trace of an asp.net app using Npgsql and I'm seeing a few things around logging that add significant bloat.

Our messages:
https://github.com/npgsql/npgsql/blob/274a1d174b44640d727f57751921541f335d6ffb/src/Npgsql/LogMessages.cs#L20

We easily add 100+ kb for Npgsql because of: #85116. Good to see it's being tracked for 9.0.

Next I noticed some of our methods have method parameters but no corresponding structured message parameter. Regardless LoggerMessageGenerator generates a TState struct and adds generic code bloat.

Continuing analysis of LoggerMessageGenerator codegen I noticed we have a ton of messages all logging the same parameters, today each gets their own struct and resulting generic code bloat throughout the logging stack. It would be useful if a Type to be used could be passed to the attribute allowing us to share definitions, or alternatively the generator might be able to do deduplication within an assembly automatically.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 27, 2023
@ghost
Copy link

ghost commented Aug 27, 2023

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

Looking at a size trace of an asp.net app using Npgsql and I'm seeing a few things around logging that add significant bloat.

Our messages:
https://github.com/npgsql/npgsql/blob/274a1d174b44640d727f57751921541f335d6ffb/src/Npgsql/LogMessages.cs#L20

We easily add 100+ kb for Npgsql because of: #85116. Good to see it's being tracked for 9.0.

Next I noticed some of our methods have method parameters but no corresponding structured message parameter. Regardless LoggerMessageGenerator generates a TState struct and adds generic code bloat.

Continuing analysis of LoggerMessageGenerator codegen I noticed we have a ton of messages all logging the same parameters, today each gets their own struct and resulting generic code bloat throughout the logging stack. It would be useful if a Type to be used could be passed to the attribute allowing us to share definitions, or alternatively the generator might be able to do deduplication within an assembly automatically.

Author: NinoFloris
Assignees: -
Labels:

area-Extensions-Logging

Milestone: -

@tarekgh tarekgh added this to the 9.0.0 milestone Aug 28, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 28, 2023
@tarekgh tarekgh added the source-generator Indicates an issue with a source generator feature label Aug 29, 2023
@tarekgh tarekgh modified the milestones: 9.0.0, 10.0.0 Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-Logging source-generator Indicates an issue with a source generator feature
Projects
None yet
Development

No branches or pull requests

2 participants