# Question regarding stream wrappers and op code cache

- Thread: https://externals.io/message/81746
- Original archive: https://news-web.php.net/php.internals/81746
- Started by Cesar Rodas on 2015-02-03T23:26:50+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #81746 — Cesar Rodas — 2015-02-03T23:26:50+00:00

URL: https://externals.io/message/81746#81746

Hi Guys,

I have a doubt, is it efficient include/require files from a source
different than the "real file system" a stream wrapper class? My
question is, would the op-code cache work as it would when reading a
file form the filesystem?

Cheers,

-- 
César D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6

---

## #81747 — Leigh — 2015-02-03T23:55:33+00:00

URL: https://externals.io/message/81746#81747 · In reply to: #81746

> Hi Guys,
>
> I have a doubt, is it efficient include/require files from a source
> different than the "real file system" a stream wrapper class? My
> question is, would the op-code cache work as it would when reading a
> file form the filesystem?
>

Do you mean if you `include 'mystream://something.php'; ?

Interesting question. I'd like to think that when opcache tries to
stat the file that streamWrapper::url_stat is called, and keeping the
mtime the same will cause the cached version to be used.

Really no idea though, I'd like to know the answer too.

---

## #81748 — Cesar Rodas — 2015-02-03T23:56:36+00:00

URL: https://externals.io/message/81746#81748 · In reply to: #81747

> 
> > […]
> Do you mean if you `include 'mystream://something.php'; ?
Yes, that's exactly what I *tried* to ask!

>
> Interesting question. I'd like to think that when opcache tries to
> stat the file that streamWrapper::url_stat is called, and keeping the
> mtime the same will cause the cached version to be used.
>
> Really no idea though, I'd like to know the answer too.
Let's wait then!

Cheers,

-- 
César D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6

---

## #81756 — reeze — 2015-02-04T03:02:14+00:00

URL: https://externals.io/message/81746#81756 · In reply to: #81746

Hi Cesar,



> Hi Guys,
>
> I have a doubt, is it efficient include/require files from a source
> different than the "real file system" a stream wrapper class? My
> question is, would the op-code cache work as it would when reading a
> file form the filesystem?
>

Yes it works if you are using 'phar' stream wrapper, the rest wrappers are
not cached,

@see
https://github.com/php/php-src/blob/master/ext/opcache/ZendAccelerator.c#L138-L142


This RFC: https://wiki.php.net/rfc/streams-is-cacheable is aim to remove
the restriction and allow stream wrapper itself to decide should it been
cached by opcache.


>
> Cheers,
>
> --
> César D. Rodas
> Open Source developer
> +595-983-161124
> PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6

---

## #81775 — francois@tekwire.net — 2015-02-04T07:19:09+00:00

URL: https://externals.io/message/81746#81775 · In reply to: #81746

> De : Cesar Rodas [mailto:cesar@rodas.me]
> I have a doubt, is it efficient include/require files from a source
> different than the "real file system" a stream wrapper class? My
> question is, would the op-code cache work as it would when reading a
> file form the filesystem?

I understand your question but, yes, the feature is essential to packages systems like phar and phk (and it is useless for most other stream wrappers). Package systems distribute a virtual file tree, handle `stat()`, and returning valid mtimes. So, the opcode cache must be able to work with these stream wrappers.

Regards

François

---

## #81822 — Cesar Rodas — 2015-02-04T16:14:05+00:00

URL: https://externals.io/message/81746#81822 · In reply to: #81775

> > […]
> I understand your question but, yes, the feature is essential to packages systems like phar and phk (and it is useless for most other stream wrappers). Package systems distribute a virtual file tree, handle `stat()`, and returning valid mtimes. So, the opcode cache must be able to work with these stream wrappers.
I'm working on a project to *put* all generated code inside a single
file (and expose through "generated://doctrine" or
"generated://<package-name>") but it's pointless if the compiled op-code
is not cached :-(

I believe this https://wiki.php.net/rfc/streams-is-cacheable would be
brilliant!

Cheers,
>
> Regards
>
> François
>
>

-- 
César D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6
