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

update static logger to sawmill #33705

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

benev0
Copy link
Contributor

@benev0 benev0 commented Dec 3, 2024

for #33279

@github-actions github-actions bot added S: Needs Review Status: Requires additional reviews before being fully accepted size/L Denotes a PR that changes 1000-4999 lines. S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. Changes: UI Changes: Might require knowledge of UI design or code. labels Dec 3, 2024
@CrafterKolyan
Copy link
Contributor

I am not an expert on the whole infrastructure stuff and not sure how all of this IOCManager works to be honest and neither the maintainer of the project. But shouldn't all of these loggers be:

private static readonly

so that we wouldn't need to create a new logger on every object instantiation?

I guess maintainers may want to comment if it makes sense to make all of them private static readonly

@CrafterKolyan
Copy link
Contributor

Ah, I checked the implementation of LogManager and saw that it actually caches loggers by name which makes sense to be honest, so strictly speaking we are not allocating a new object, though I guess every object that contains logging will have extra 3 fields. I guess we can definitely move string one to be static to optimize at least that. Not sure about the other ones, as I guess we pay the cost of 16 bytes per logged object in memory to make the logging testable?

In the end I guess none of this may matter at this point as I saw other places where static optimization may be made but I guess IOCManager complicates the actual ability to use static variables.

@benev0
Copy link
Contributor Author

benev0 commented Dec 3, 2024

forgot to post this:
Due to nearly identical code behaving differently within different regions, I have used multiple patterns. This is roughly where I targeted the patterns.

  • static + (log on critical fail only)
  • full injection (managers)
  • lazy singleton (multiple log calls on the same object)

There was a lot of trouble with null deref segfaults (and may still be)

@ScarKy0 ScarKy0 added P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. T: Cleanup Type: Code clean-up, without being a full refactor or feature D2: Medium Difficulty: A good amount of codebase knowledge required. A: Core Tech Area: Underlying core tech for the game and the Github repository. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: Core Tech Area: Underlying core tech for the game and the Github repository. Changes: UI Changes: Might require knowledge of UI design or code. D2: Medium Difficulty: A good amount of codebase knowledge required. P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. S: Needs Review Status: Requires additional reviews before being fully accepted size/L Denotes a PR that changes 1000-4999 lines. T: Cleanup Type: Code clean-up, without being a full refactor or feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants