Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 59171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:57:48+00:00 2026-05-10T17:57:48+00:00

I have a colleague who is looking into opcode caching/Zend Acceleration (I’ve always assumed

  • 0

I have a colleague who is looking into opcode caching/Zend Acceleration (I’ve always assumed these are the same thing) for our PHP based application. His Benchmarks appear to indicate that we’re NOT seeing a performance benefit if we include our (large) class libraries with require_once, but we DO see the performance benefit when using include_once.

This smells fishy to both of us, but I don’t have time to check into our benchmark methodology myself and my colleague has more tolerance for the smell of fish than I do. 🙂

Has anyone ever run into anything like this? If not, any thoughts on other things that might be causing the appearance of a performance increase by switching from include_once to require_once?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:57:49+00:00Added an answer on May 10, 2026 at 5:57 pm

    For starters, both calls (require_once and include_once) double-check if a file has not been included before.

    So the way they both achieve this is by searching the file in all available paths and by essentially checking if it hasn’t been in the mix before etc..

    In the background what happens is that they evaluate all the different options (e.g. multiple include_path’s, etc.) and then by creating the realpath from this abreviated form they create a unique identifier. There is only one and the same path – not two.

    This is already not the fastest process on the planet and generally happens on each request with PHP. Then add another expensive operation which is the stat when it creates what I called the realpath (realpath, because it’s sort of what realpath() does) to check if the file exists.

    Correct me if I am wrong, but APC has optimizations especially for this case.

    So anyway – now on to the difference between require_once and include_once, which is that require_once evaluates the file (for low-level parse errors, etc.) when it includes it. This is an additional check which you can get rid of if you have enough QA in place that a parse error can never sneak into an include.

    It’s just tricky to find otherwise. 🙂

    (Something to consider: You could develop with require_once and replace all calls with include_once when you deploy.)

    As for an opcode cache – I’d recommend APC. It’s been discussed on stackoverflow before. Personally, I am/we are using it for a while (we handle roughly 100k visitors/day with 3 frontends and 1 backend) and we are very happy. APC is also optimized for the require_once/include_once madness.

    A pretty cool side-effect is that APC also allows you to store PHP variables in memory – sort of persistant, etc..

    A couple additional pointers:

    1. A lot of people claim to speed up any application with __autoload.
    2. With an opcode cache, avoid conditional require_once/include_once (e.g. in loops or in control-flow).
    3. Some people say that /absolute/path/to/file.php in include_ or require_once is faster than relying on the include_path.
    4. The order of the paths in your include_path matters as well.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a colleague who always writes ISNULL(COUNT(*),0) , but I always thought
I have a colleague who insists that his code doesn't need comments, it's "self
I have a colleague who has been using PHP's mysql_pconnect() without my knowing it.
I don't use Tcl in my daily work. However, I have a colleague who
Hello I have a colleague of mine who is a procedural code developer and
Let's say I have file secret_config in .git/info/exclude . My colleague, who doesn't know
I've got a couple of colleagues who love Access and have lots of important
I have a good friend (my old college roommate, actually), who critiques my personal
I have a colleague in my company whose opinions I have a great deal
Myself and a colleague have a dispute about which of the following is more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.