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

Remove model name sub-collision logging #2214

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

emhovis
Copy link

@emhovis emhovis commented Feb 6, 2024

With all of the love this bundle has recently been getting, I got tired of manually removing the logging functionality every update to be able to actually use my local environment's OA docs.

This should alleviate a good chunk of the problems referenced in #2099
Rather than logging ~n^2/2 average times per shared name, this change cuts it down to at most once per shared name. There's still quite a bit of logging, but this cuts down the number of logs by an order of magnitude... so I'd say its a good start. If you have 1000 models named "image", and load the entire doc reference, the current package would generate ~500k logs but with the changes in this PR would only generate 999.

I'd prefer if it were an option we could opt out of logging it in its entirety via a config var but I've spent far too long trying to makeshift that to work.

@emhovis
Copy link
Author

emhovis commented Feb 6, 2024

Ideally I'd have liked to log the number of times its being reused, but the current testing is a bit shallow on capabilities. I could just hardcode the "is being used 2 times." into the test and it'd pass phpunit but that is a bit misleading since we're only testing a collision depth of 1... Then again, current testing doesn't take secondary collisions into account so I guess both ways are a tad misleading...

Sorry for the mention, but as the person leading the recent surge of maintenance, I figured your input would be valuable- Do you have any thoughts @DjordyKoert

@DjordyKoert
Copy link
Collaborator

DjordyKoert commented Feb 13, 2024

Ideally I'd have liked to log the number of times its being reused, but the current testing is a bit shallow on capabilities. I could just hardcode the "is being used 2 times." into the test and it'd pass phpunit but that is a bit misleading since we're only testing a collision depth of 1... Then again, current testing doesn't take secondary collisions into account so I guess both ways are a tad misleading...

I don't think it hurts to rewrite the current test to ensure this doesn't happen again.

@DjordyKoert
Copy link
Collaborator

I'd prefer if it were an option we could opt out of logging it in its entirety via a config var but I've spent far too long trying to makeshift that to work.

Since #2131 it's possible to pass a NullLogger. to the ApiDocGenerator (or manually call setLogger). Would that not be a solution for you?

@emhovis
Copy link
Author

emhovis commented Feb 13, 2024

I'd prefer if it were an option we could opt out of logging it in its entirety via a config var but I've spent far too long trying to makeshift that to work.

Since #2131 it's possible to pass a NullLogger. to the ApiDocGenerator (or manually call setLogger). Would that not be a solution for you?

That actually mostly fixes my issue. Can't believe I missed that getting added!
On a side note, I still think it'd be ideal to pass this PR. I still don't see the need for logging an entire loop of previous collision instances for each new collision as default behavior.

@emhovis
Copy link
Author

emhovis commented Feb 13, 2024

I'd prefer if it were an option we could opt out of logging it in its entirety via a config var but I've spent far too long trying to makeshift that to work.

Since #2131 it's possible to pass a NullLogger. to the ApiDocGenerator (or manually call setLogger). Would that not be a solution for you?

That actually mostly fixes my issue. Can't believe I missed that getting added! On a side note, I still think it'd be ideal to pass this PR. I still don't see the need for logging an entire loop of previous collision instances for each new collision as default behavior.

I stand corrected- it appears that the Symfony Profiler captures all logged items regardless of whether a nullhandler is used to "blackhole" them or not. My Symfony Profiler still OOMs the browser when trying to view the logs for the /doc page.

As a bit of an experiment, I set monolog to separate the Nelmio logs into their own file- it generates a ~290mb logfile of name collisions for 1 /doc request.

With the changes in this PR, the logfile generated for the /doc page is only ~4mb and my browser doesn't crash. I'd call that a good start.

@DjordyKoert
Copy link
Collaborator

I am happy to merge this if you could write some tests for this (probably by rewriting the current test).


if ($i > 1) {
if (isset($this->registeredModelNames[$base])) {
$this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $base), [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $base), [
$this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has been taken %d times.', $base, $i), [

@emhovis emhovis marked this pull request as draft April 2, 2024 18:40
@shakaran
Copy link
Contributor

shakaran commented May 1, 2024

@emhovis could you rebase with last updates? Thanks

@emhovis
Copy link
Author

emhovis commented May 1, 2024

@emhovis could you rebase with last updates? Thanks
Done.

Things are slowing down a bit for me, I'll see if I can set some time aside soon for writing those tests so we can finally get this merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants