# Expose zend_message_dispatcher_p

- Thread: https://externals.io/message/64000
- Original archive: https://news-web.php.net/php.internals/64000
- Started by Laruence on 2012-11-21T02:39: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

---

## #64000 — Laruence — 2012-11-21T02:39:50+00:00

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

Hey:

   This problem come out when I was figuring a performance issue of Yaf_Loader.

   Yaf provides a autoloader like PSR0,  when doing a classes
autoloading. it used to:

   1. stat the file,  if file does not exists,  return
   2. zend_compile_file

   this is okey when you  run yaf without opcode cache.

   but when you run yaf with opcode cache,  the first stat syscall
become a little waste.

   since opcode cache always hook the zend_compile_file, and compile
the file from cache.

   so,  I changed the autoload to:

    1. zend_compile_file
    2. if compile failed, then return.

   but,  zend_compile_file will throw warning if the file doesn't
exists via zend_message_dispatcher_p

   so if zend_message_dispatcher_p is ZEND_API, then I can avoid using
such mess codes:
https://github.com/laruence/php-yaf/blob/master/yaf_loader.c#L377

   what do you think?


thanks
-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #64012 — Dmitry Stogov — 2012-11-21T06:35:09+00:00

URL: https://externals.io/message/64000#64012 · In reply to: #64000

[see below]



> Hey:
>
>    This problem come out when I was figuring a performance issue of
> Yaf_Loader.
>
>    Yaf provides a autoloader like PSR0,  when doing a classes
> autoloading. it used to:
>
>    1. stat the file,  if file does not exists,  return
>    2. zend_compile_file
>
>    this is okey when you  run yaf without opcode cache.
>
>    but when you run yaf with opcode cache,  the first stat syscall
> become a little waste.
>

You should just use  virtual_realpath() or tsrm_realpath() instead of
 `stat()`. They must utilise realpath cache and avoid `stat()` calls.

Thanks. Dmitry.


>    since opcode cache always hook the zend_compile_file, and compile
> the file from cache.
>
>    so,  I changed the autoload to:
>
>     1. zend_compile_file
>     2. if compile failed, then return.
>
>    but,  zend_compile_file will throw warning if the file doesn't
> exists via zend_message_dispatcher_p
>
>    so if zend_message_dispatcher_p is ZEND_API, then I can avoid using
> such mess codes:
> https://github.com/laruence/php-yaf/blob/master/yaf_loader.c#L377
>
>    what do you think?
>
>
> thanks
> --
> Laruence  Xinchen Hui
> http://www.laruence.com/

---

## #64015 — Laruence — 2012-11-21T07:56:16+00:00

URL: https://externals.io/message/64000#64015 · In reply to: #64012

> [see below]
>
> 
> > […]
>
>
> You should just use  virtual_realpath() or tsrm_realpath() instead of
> `stat()`. They must utilise realpath cache and avoid `stat()` calls.
Hey:

  Thanks, Dmitry,

  actually,  I didn't do like that is because by default, realpath
cache has 2min ttl.

  but, after a second think,  I think this will be better than my
current tricky implementation.. I will try in this way :)

thanks
>
> Thanks. Dmitry.
>
> > […]
>
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #64017 — Dmitry Stogov — 2012-11-21T08:14:32+00:00

URL: https://externals.io/message/64000#64017 · In reply to: #64015

Great! I always glad to help. And I would avoid "tricky" solutions as much
as possible. :)

Even 2 minutes TTL is going to save few thousands syscalls, in case your
site is really
high loaded, and it make no sense to care about "last syscall optimization"
if you system is mostly idle.

BTW: I'm not sure if APC calls `stat()` for inclode_once(), but it definitely
possible not to call it.

Thanks. Dmitry,



> 
> > […]
> Hey:
>
>   Thanks, Dmitry,
>
>   actually,  I didn't do like that is because by default, realpath
> cache has 2min ttl.
>
>   but, after a second think,  I think this will be better than my
> current tricky implementation.. I will try in this way :)
>
> thanks
> > […]
>
>
>
> --
> Laruence  Xinchen Hui
> http://www.laruence.com/

---

## #64018 — Pierre Joye — 2012-11-21T08:25:34+00:00

URL: https://externals.io/message/64000#64018 · In reply to: #64017

hi Dmitry,


> Great! I always glad to help. And I would avoid "tricky" solutions as much
> as possible. :)
>
> Even 2 minutes TTL is going to save few thousands syscalls, in case your
> site is really
> high loaded, and it make no sense to care about "last syscall optimization"
> if you system is mostly idle.
>
> BTW: I'm not sure if APC calls `stat()` for inclode_once(), but it definitely
> possible not to call it.

It has been a long todo to remove some of the stat calls in APC. It
would be nice if you could give a hand here :)

Cheers,
--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #64021 — Dmitry Stogov — 2012-11-21T08:46:41+00:00

URL: https://externals.io/message/64000#64021 · In reply to: #64018

Hi Pierre,

Sorry, but I'm really busy to support APC.
I  may explain the working solution once again, but according to coding I
would prefer to spend
my "free" time looking into php-5.5 problems and possible new performance
improvements.

Thanks. Dmitry.



> hi Dmitry,
>
> 
> > […]
> much
> > […]
> optimization"
> > […]
> definitely
> > […]
>
> It has been a long todo to remove some of the stat calls in APC. It
> would be nice if you could give a hand here :)
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
