xcache是​​如何工作的?代码覆盖率?木? OOM? [英] xcache how does it work? code coverage? clogs? OOMs?

查看:120
本文介绍了xcache是​​如何工作的?代码覆盖率?木? OOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上搜索了文档,包括在 XCache网站上.

I've searched all over the web for documentation including on the XCache website.

我是PHP操作码缓存和XCache的新手.我想解释一下XCache的工作原理.我知道它存储已编译的php代码,因此不需要每次都重新编译.但是XCache如何知道何时更新了php代码,从而导致缓存已过期?

I'm new to PHP opcode caching and XCache. I'd like an explanation of how XCache works. I know that it stores compiled php code so that it doesn't need to be recompiled everytime. But how does XCache know when php code has been updated and thus the cache is out of date?

我怎么知道是否需要清除缓存?

How do I know if I need to clear the cache?

XCache是​​否在服务器上编译并缓存所有个php代码?如果可以,可以配置它吗?

Does XCache compile and cache all php code on the server? If so can this be configured?

什么是木log? OOM?在XCache Admin页面界面中,我看到这两个数字很大.

What are clogs? OOMs? I see large numbers for both of these in the XCache Admin page interface.

在代码覆盖率查看器"中...百分比是什么意思?这是已缓存的代码的百分比吗? 命中次数是否意味着已从缓存中读取的已编译代码的行数? 行数是否意味着代码的总行数? 待办事项"列的用途是什么? 为什么有些行用红色突出显示?

In the Code Coverage Viewer... what does Percent mean? Is this the percentage of code that has been cached? Does hits mean the number of lines of compiled code that has been read from cache? Does lines mean the total number of lines of code? What is the ToDo column for? Why are some lines highlighted in red?

我正在使用PHP 5.3.2,XCache 1.3.0和Ubuntu 10.04(如果有帮助的话).

I'm using PHP 5.3.2, XCache 1.3.0, and Ubuntu 10.04 if it helps.

推荐答案

Xcache :

通过消除PHP脚本的编译时间来优化性能 通过将PHP脚本的编译状态缓存到shm(RAM)中 直接从RAM使用编译的版本.

optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM.

基于对 PHP 5.5.3和Xcache 3.1.0 的观察,我可以得出以下结论:

Based on observations using PHP 5.5.3 and Xcache 3.1.0 this is what I can deduce:

此模块处理两种缓存 操作码 变量.

This module deals with two kinds of caching Opcode and Variable.

操作码缓存被设计为一个简单的插件.您无法自定义其决定缓存的方式,只能自定义多少:

The Opcode caching is designed to be a simple drop-in. You can't customize how it decides to cache, just how much:

  • xcache.count 设置是指有多少个缓存线程并与您要使用的处理器核心相关联-这个想法是内存不足,是指缓存线程命中最大尺寸
  • xcache.count setting refers to how many cache threads and correlates to how many processor cores you want to utilize — the idea is that multithreading should be the fastest, but there is no guarantee so experiment yourself
  • As a guideline, valid count values would be 2^n like 1, 2, 4, 8 — 0 will disable the cacher and other values will get rounded to the nearest valid value
  • xcache.size setting refers to the aggregate memory of all cache threads. So, each thread gets roughly size/count amount of memory
  • OOM aka Out of Memory, refers to the event of a cache thread hitting it's maximum size

可变缓存要求在您的应用代码中使用简单的get/set api.使用 xcache.var_size xcache.var_count (类似于操作码设置)启用它后,您可以在脚本中使用xcache_set($var1)xcache_get($var1).

Variable caching requires using a simple get/set api in your app code. After enabling it using xcache.var_size and xcache.var_count (similar to Opcode settings) you use xcache_set($var1) and xcache_get($var1) in your scripts.

xcache.stat 设置控制是否检查文件自缓存以来是否已修改:

The xcache.stat setting controls whether or not to check if the file was modified since it was cached:

  • 设置为打开时,文件将被检查并重新缓存
  • 当设置为 Off 时,跳过该检查将使第一个缓存的版本保持与到期时间一样长的时间,这可以通过限制磁盘I/O来帮助提高性能.
  • >
  • When set to On files get checked and re-cached
  • When set to Off skips the check will keep the first cached version as long as the expiration time, which could help performance by limiting disk i/o

在您的开发环境中,最好将其保持为打开,以便您可以连续更新和检查代码-否则,您必须清空缓存以查看文件更新.

In your dev environment it's a good idea to keep it On so you can update and check your code continuously — otherwise you have to flush the cache to see updates to files.

有一个Web管理界面,可让您刷新特定的缓存.网络管理员使用php API:xcache_clear_cache(…).

There is a web admin interface which allows you to flush a particular cache. The web admin uses a php api: xcache_clear_cache(…).

由于缓存是基于RAM的,因此只要服务器重新启动,就应刷新缓存.

Since the cache is RAM based anytime the server restarts the cache should be flushed.

缓存项根据xcache.ttlxcache.var_ttl到期,它们分别控制缓存项的生存秒数(0是不确定的,是默认值).

Cached items expire according to xcache.ttl and xcache.var_ttl which respectively control the number of seconds a cached item lives (0 is indefinite and the default).

coverager模块又名Code Coverage,有点神秘.根据 FeatureList ,它看起来像是一种诊断工具,旨在用于临时管理/测试情况:

The coverager module, aka Code Coverage, is a little mysterious. According to the FeatureList it seems like a diagnostic tool intended to be enabled for temporary administrative/testing situations:

  • Coverager +现实生活中的测试用例框架,包括:[TOSHARE]
    • 真实生活的测试用例框架,带有真实浏览器的控制脚本.您必须编写测试用例.
    • 内置Coverager及其Web查看器,以查看您测试了多少脚本.
  • Coverager + real life testcase framework, this include: [TOSHARE]
    • real life testcase framework, a control script with real browser. you have to write the test cases.
    • builtin Coverager + its viewer from web, to see how much script you have tested.
  • 启用XCache后
  • 将php4升级到php5
  • 将php4/5升级到php6
  • after enabling XCache
  • after upgrading php4 to php5
  • after upgrading php4/5 to php6

这篇关于xcache是​​如何工作的?代码覆盖率?木? OOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆