Skip to content

[DI] fine tune dumped factories #27268

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

Merged
merged 1 commit into from
May 17, 2018
Merged

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Here is an optimization we forgot in the dumped container: when a private service is referenced once, there is no need to keep it in the internal registry as it will never be reused. This should help a bit the garbage collection process.

@ogizanagi
Copy link
Contributor

Can't we merge this in lower branches too?

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented May 15, 2018

that's not a bugfix but an improvement, so that's for master

continue;
}
$ids = array();
foreach ($node->getInEdges() as $edge) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend to extract that whole logic into a new private method for clarity.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -68,6 +69,7 @@ class PhpDumper extends Dumper
private $inlineRequires;
private $inlinedRequires = array();
private $circularReferences = array();
private $singlePrivateIds = array();
Copy link
Member

@javiereguiluz javiereguiluz May 15, 2018

Choose a reason for hiding this comment

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

Minor comment. I didn't like the $singlePrivateIds var name, so I looked for English words that mean "used once" and maybe it could be better to rename this to $singleUsePrivateIds

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@@ -1798,6 +1804,22 @@ private function isHotPath(Definition $definition)
return $this->hotPathTag && $definition->hasTag($this->hotPathTag) && !$definition->isDeprecated();
}

private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node)
Copy link
Contributor

Choose a reason for hiding this comment

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

bool return declaration?

Copy link
Member Author

Choose a reason for hiding this comment

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

not on 3.4

Copy link
Member Author

Choose a reason for hiding this comment

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

but OK on master :)

@fabpot
Copy link
Member

fabpot commented May 17, 2018

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 88ecd0d into symfony:master May 17, 2018
fabpot added a commit that referenced this pull request May 17, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

[DI] fine tune dumped factories

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Here is an optimization we forgot in the dumped container: when a private service is referenced once, there is no need to keep it in the internal registry as it will never be reused. This should help a bit the garbage collection process.

Commits
-------

88ecd0d [DI] fine tune dumped factories
@nicolas-grekas nicolas-grekas deleted the di-leaner-dump branch May 20, 2018 09:15
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.1 Nov 1, 2018
This was referenced Nov 3, 2018
nicolas-grekas added a commit that referenced this pull request Dec 2, 2018
…services (chalasr)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Fix dumping expressions accessing single-use private services

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29403
| License       | MIT
| Doc PR        | n/a

Introduced in #27268, see fixed ticket

Commits
-------

d1e84aa [DI] Fix dumping expressions accessing single-use private services
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.

7 participants