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

Use stream wrapper to extract files on demand. #1

Open
kherge opened this issue Aug 3, 2016 · 2 comments
Open

Use stream wrapper to extract files on demand. #1

kherge opened this issue Aug 3, 2016 · 2 comments

Comments

@kherge
Copy link
Member

kherge commented Aug 3, 2016

Problem

After creating some rough benchmarks for runtime performance comparison between PHAR and Sqon, I realized that the first run for a PHAR kicked Sqon's butt. I believe that this has something to do with the phar extension's support for stream wrapping. An attempt should be made to offer something similar with Sqon.

Resolution

I am hoping to see faster run times when a Sqon is first run and for each subsequent run. This improvement should take advantage of PHP's optimizations (i.e. opcode caching).

References

  1. https://github.com/php/php-src/blob/master/ext/phar/stream.c
  2. https://secure.php.net/manual/en/class.streamwrapper.php
  3. https://secure.php.net/manual/en/book.opcache.php
@kherge
Copy link
Member Author

kherge commented Aug 19, 2016

I am currently trying to figure out if there is a net benefit using a stream wrapper.

Research

These are questions that need answering.

  • Does opcode caching work for stream wrappers?
  • How long does it take to extract the embedded database?
  • How long does it take to include a file (extracted and stream wrapped)?

Opcode Caching

Opcode caching is not supported for streams. @flaupretre is working on adding support1, 2, 3, but I'm not sure if it's going to make it to the 7.1 release. Since Sqon will only be supporting current LTS releases, this functionality is considered non-existent at the moment.

The conclusion is that opcode caching does not support streams at the moment. As a consequence, using stream wrapping will not be as performant as extracting the Sqon to the filesystem. The only benefit is reducing the startup time for a command line application. I should probably consider providing this as an alternative PHP bootstrap script.

  1. https://wiki.php.net/rfc/streams-is-cacheable
  2. Add is_cacheable() stream wrapper operation php/php-src#976
  3. New 'cache_key' streams operation php/php-src#1711

Extract vs Streaming Times

Using rough benchmarks, I received the following times for executing a Symfony 3 (symfony/framework-standard-edition) application console:

  • Stream: 0.713 seconds
  • Extract: 2.807 seconds
  • Post Extract: 0.187 seconds

The 0.713 seconds is a very noticeable pause and is enough for me to determine that support streaming is not a viable option at this time. When an LTS version of PHP with stream caching support is available, this potential enhancement must be revisited.

@kherge kherge closed this as completed Aug 20, 2016
@kherge kherge added the on hold label Aug 20, 2016
@kherge
Copy link
Member Author

kherge commented Feb 1, 2020

I'm reopening this issue to investigate the possible use of opcache_compile_file.

@kherge kherge reopened this Feb 1, 2020
@kherge kherge removed the on hold label Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant