6

I'm using APC (3.1.9) and Zend Framework, however, only a bunch of file are being cached (something like 10 / 400).

Do you have any ideas? I'm using the factory options on a debian installation.

EDIT: It looks like the only file which are opcached are the one I manually call with require ''; however the ones which are loaded by my autoloader are not. Any ideas?


Runtime Settings

apc.cache_by_default    1
apc.canonicalize    1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enabled 1
apc.file_md5    0
apc.file_update_protection  2
apc.filters 
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes    0
apc.lazy_functions  0
apc.max_file_size   1M
apc.mmap_file_mask  
apc.num_files_hint  1000
apc.preload_path    
apc.report_autofilter   1
apc.rfc1867 0
apc.rfc1867_freq    0
apc.rfc1867_name    APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.serializer  default
apc.shm_segments    1
apc.shm_size    32M
apc.slam_defense    1
apc.stat    1
apc.stat_ctime  0
apc.ttl 0
apc.use_request_time    1
apc.user_entries_hint   4096
apc.user_ttl    0
apc.write_lock  1

here is apc.php screenshots apc.php

The files that are getting opcached php code

And the index.php (ZF) where I require files and register autoloader within Zend_Loader_Autoloader.

opcached files

Trent
  • 5,785
  • 6
  • 32
  • 43
  • 2
    What are the values of apc.shm_segments and apc.shm_size? And what is 'like 10/400' how did you determine that number ? – meze Dec 17 '11 at 15:59
  • hi, I added the entire runtime configuration, 10/400 means that using Zend Framework and others libraries, I've around 400 files which are loaded on each request, but only 10 are opcached. – Trent Dec 18 '11 at 11:00
  • 1
    Again, how is it that you are determining, that you have 390 misses. :) – Layke Dec 19 '11 at 17:44
  • 1
    http://stackoverflow.com/questions/1396501/do-php-opcode-cache-work-with-autoload – Petah Dec 20 '11 at 04:51
  • @Layke, well, I know that I've ~400 files loaded, and only 10 are opcached, I see them in the apc.php script provided by Apc. – Trent Dec 20 '11 at 17:29
  • Yup. That was what I was getting at. So after like an hour of usage, what are yout hit and miss percentages? – Layke Dec 20 '11 at 18:07
  • @Layke, Uptime 1 day, 5 hours and 14 minutes, Hits 22448 Misses 26 Request Rate (hits, misses) 0.21 cache requests/second Hit Rate 0.21 cache requests/second Miss Rate 0.00 cache requests/second – Trent Dec 20 '11 at 19:12
  • Trent can you provide a screenshot? like this: http://i.stack.imgur.com/F0QyD.jpg – Layke Dec 20 '11 at 20:22

2 Answers2

1

Probably one of the biggest downside to autoloading is that op cache doesn't cache autoloaded files as one would hope (something about autoload being runtime vs. include/require being compile time. Or not. I dont claim to understand it.). Read more here.

While I never tried, I wonder if manually adding your autoloaded file to the cache by calling apc_compile_file() in the autoloader would, effectively, solve this issue?

Mbrevda
  • 2,888
  • 2
  • 27
  • 35
  • Hi, thanks for your suggestion, however what's weird is that I didn't reproduce that problems on another environement, I wonder it is a configuration or environment related set up which causes this. By the way I could try to manually add that call to my autoloader but just "to check" because I'm not gonna patch the library I'm using. – Trent Dec 22 '11 at 19:05
  • My point is/was in response to your original question: opcache and autoloading dont play nicely. I've updated my post with a link. – Mbrevda Dec 24 '11 at 23:41
  • APC caches autoloaded files just fine. There is some performance penalty for conditionally defined functions and classes (one form of which is autoloaded classes), but that has little to do with file-level opcode caching. – Tgr Dec 25 '11 at 00:56
0

For some reasons apc.cache_by_default was set to OFF, an my files were not getting cached correctly, which is logical given this config, however, I still don't understand why those I manually required was actually cached.

Trent
  • 5,785
  • 6
  • 32
  • 43