Support pre-built code artifacts & HHVM's repo authoritative mode

Created on 27 October 2016, almost 9 years ago
Updated 6 March 2024, over 1 year ago

I'm creating this as a meta-issue to track my progress towards support for building a Drupal 8 site codebase into a pre-built artifact that can be used by HHVM's repo authoritative mode. For those unfamiliar, repo auth mode pre-compiles all PHP code into a bytecode repo which cannot be altered without recompiling the bytecode database and restarting the server daemon. The performance gains for Drupal 8 stand to be enormous -- I've measured roughly a +50% increase in requests per second over baseline HHVM on basic D8 workloads. This is basically thanks to how well HHVM interacts with D8's highly OOP codebase -- the gains for D7 were far smaller.

This means that all code (particularly Twig templates) needs to be compiled before the server is started. In addition, it's common for codebases to be compiled on environments which have no knowledge of the site's live environment (i.e. database storage and caches) so an ideal path would find a way to compile all dynamic code without needing database access at all.

I spoke a little about this with dawehner at BADCamp recently and with his help got far enough with the initial issues to pursue this. Here's what we have so far:

  • Twig templates have a Drush command to pre-compile them, but it is currently a little broken. An initial PR for Drush is here: https://github.com/drush-ops/drush/pull/2416
  • I'd like to do more work on the above to make the command usable without a database. I ran this by laurii and joelpittet and they seemed to think it was plausible by writing some substitute classes for the theme registry and Twig cache backend, but I have no idea how hard that'll be yet.
  • To make Twig template pre-compilation work, we need to unify the way { % include % } templates and namespaced templates are handled. An issue with a patch is here: #2822470: Unified cache key & template class handling for Twig templates β†’
  • The MTimeProtected file storage classes appear to change the cache keys for templates on a cache clear (at least under certain circumstances.) This naturally breaks the pre-compiled templates. However, since no new code can be executed, MTimeProtected PHP storage isn't actually necessary and can be replaced with simple FileStorage (for the build process) and FileReadOnlyStorage (for production environments.) This can be handled in settings.php and just needs to be documented.
  • Drupal 8 uses a ton of string assertions. Since these are essentially the same as eval(), HHVM doesn't support these in authoritative mode. However HHVM users can disable assertions in their INI file (assert_options() is not good enough, sadly) so this also just needs to be documented.
🌱 Plan
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Kazanir

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    There has been no progress reported here in the 7 years this has been open. Is this tracking issue still needed?

    I am settomg the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Status changed to Closed: works as designed 4 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Another year has no confirmation that this is to be pursued. Therefore, closing this issue.

    If there is interest in this re-open the issue and add a comment. Or open a new issue and reference this one.

Production build 0.71.5 2024