Skip to content

Benefit from pre-warmed cache in console/worker context #41

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 2 commits into from
Apr 25, 2021

Conversation

t-richard
Copy link
Member

No description provided.


return parent::handle($request, $type, $catch); // TODO: Change the autogenerated stub
parent::boot();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't boot() called in the case of HTTP too? Do we risk the case of calling prepareCacheDir() twice?

Good idea though, I'm just curious about that specific point.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be called twice indeed but the second time it would be skipped because of the first if statement in prepareCacheDir.

is_dir($writeDir) would be true so it would exit directly, as it does when hitting a warm Lambda.

Copy link
Member

Choose a reason for hiding this comment

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

Right, thanks. Then would it make sense to remove the call from handle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically Kernel::boot was previously used by the bridge but a feature added in Symfony 5.2 introduced Kernel::preBoot (obviously executed before Kernel::boot) and preBoot was dumping the cache and container before we had a chance to copy it to /tmp.

The call in Kernel::handle was introduced in #37 to fix this issue with Symfony 5.2 and make the bridge work on all versions of Symfony.

That fixed it for HTTP apps but broke it for Console apps/workers/scheduled commands because Kernel::handle is never called in a console context but kernel::boot is (and it's ok to put it here because Kernel::preBoot is never called either in console).

So I don't see any other way of making it work for both HTTP and Console 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Oh right 😅 thank you for the history, that makes sense then!

Thank you!

@mnapoli mnapoli merged commit 6156395 into brefphp:master Apr 25, 2021
@t-richard t-richard deleted the benefit-from-warm-cache-console branch April 25, 2021 21:11
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.

2 participants