Skip to content

[HttpKernel] wrap compilation of the container in an opportunistic lock #33701

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
Oct 2, 2019

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Sep 25, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

#32764 (comment)

This PR adds a lock around the compilation of the container. When two or more concurrent requests want to compile the container, the first one runs the computation and the others wait for its completion. If for any reasons the lock doesn't work, compilation happens as usual.

The effect is visible when developing locally:

Here is what all concurrent requests consume now:
image

And here is what they will consume with this PR (they wait but reuse the just compiled container):
image

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

This is really nice and the results are great! Thanks Nicolas.

@fabpot
Copy link
Member

fabpot commented Oct 2, 2019

Thank you @nicolas-grekas.

fabpot added a commit that referenced this pull request Oct 2, 2019
…pportunistic lock (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] wrap compilation of the container in an opportunistic lock

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

#32764 (comment)

This PR adds a lock around the compilation of the container. When two or more concurrent requests want to compile the container, the first one runs the computation and the others wait for its completion. If for any reasons the lock doesn't work, compilation happens as usual.

The effect is visible when developing locally:

Here is what all concurrent requests consume now:
![image](https://user-images.githubusercontent.com/243674/65603626-4e231d00-dfa6-11e9-8b6c-62dbd5eb30fe.png)

And here is what they will consume with this PR (they wait but reuse the just compiled container):
![image](https://user-images.githubusercontent.com/243674/65603733-7f9be880-dfa6-11e9-930b-ce793c3e280c.png)

Commits
-------

0b5b3ed [HttpKernel] wrap compilation of the container in an opportunistic lock
@fabpot fabpot merged commit 0b5b3ed into symfony:4.4 Oct 2, 2019
@nicolas-grekas nicolas-grekas deleted the hk-lock branch October 8, 2019 11:49
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
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.

5 participants