We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24253
    • 125 Posts
    Hi,

    I created a test case with the same pathern as modx calls the executeParse functions, but allas, it just works!
    Lots of "hello worlds" printed.

    So, somehow the problem isn’t about include’s either, though, it shows up under a certain (include) condition. I’m getting lost actually, it would be much better if I’d have access to the server, so there would be the possibility to get more information.


    While I was looking at the code, I saw few stuff left there par my advice ;-)
    Perhaps, it makes sense to remove it, or well, clear it up.

    Performance is always an issue, and in the etomite days, a request was made to stress test the system.
    So I did, and one thing which hurted performance were included files.

    It turned out that having the code from an included file hardcoded in for example index.php (or everything in index.php for that matter) significantly reduced total time spent in php.

    One such included file which was moved to index.php was the config.inc.php

    I still see the option around in index.php to hardcode the configuration settings, but config.inc.php has more in there (the startCMSSession()) so it doesn’t make sense to predefine variables anymore in index.php, or move all code from config.inc.php into index.php ;-) (So you have to again specify the configuration by hand in index.php)

    For that very reason, the log() function was also moved into index.php, which has now moved to document.parser.class.inc.php

    Putting all code into one file speeds up page generation, but has one major drawback, it uses _much_ more memory for each instance!!

    As long as your server has enough memory, no problem. But as soon as memory gets low, page generation time degrades enormously, due well, out of memory problems... (page swapping to hard disk, etc)

    Of course, when you use a php accelerator, having a number of included files has much less impact then it will have _without_ an php accelrator, but it wouldn’t hurt to measure the tradeoff between page generation time and memory consumption by having rather large php files or splitting into more php files and include on demand (document.parser.class.inc.php is quite large!)


    Oh, just thought about another thing.
    These work both:

    include_once $this->config["base_path"]."manager/includes/extenders/getuserdata.extender.php";

    include_once "manager/includes/extenders/getuserdata.extender.php";

    So, the current path is taken from index.php....
    I wonder if it makes sense to use base_path configuration  at all then?
    Anyway, the cache files are included by the second way, so if the idea was to move everything to teh first way of doing includes, it has to be changed smiley

    Thanks for your time, and hopefully my include problems will vanish somehow!

    Best wishes,

    Remon
      • 32963
      • 1,732 Posts
      Hi Remon,

      Very good observation. I guess we can look at a way to allow users to make the adjustments.

      Any suggestions?
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 25663 MODX Staff
        • 12,272 Posts
        Remon,

        Thanks indeed for your great insights. Looking forward to your recommendations on how to best-address the performance and include situation for future releases.

        :)
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 24253
          • 125 Posts
          Thanks,

          But it has been some time ago I did those measurements, and after a very short test, it appeared that with a php accelerator one included file less didn’t make any difference, though I didn’t look for memory usage.

          At that time, I installed a php profiler to see what was going on, so to make any recommendations, I’ll have to do that again ;-)

          But perhaps, this should be done when you’re nearing the 1.0.0 release. I just googled a year ago on php profiling, and read a few related articles, so it’s not actually my insight hehe.

          At the time modx 1.0.0 is nearing release, I’m happy to do some profiling for you!
          (I’m a real optimization freak you know smiley )

          Greetz,

          Remon

          (P.S.
          Hunting for optimization cases too early can led to fragile code or in some situations, you’ll rewrite part of it, and thus throw away your optimization! I suppose this is true for all languages, but at least this is the recommendation I’ve read for writing C++ code)
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Young, hot-shot programmer: My code is half the size of yours and runs twice as fast!

            Older, experienced programmer: Yes, that’s true, but my code works.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 24253
              • 125 Posts
              Quote from: sottwell at Nov 07, 2005, 09:34 AM

              Young, hot-shot programmer:  My code is half the size of yours and runs twice as fast!

              Older, experienced programmer:  Yes, that’s true, but my code works.

              Hmm, half the size?

              In my experience code optimizations involves _more_ code smiley

              It’s nice when a product is finished feature wise to start analyzing the code, code paths, and quick and dirty implementations, and change them to make it fast _and_ working ;-)

              Greetz,

              Remon
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                That’s a quote from a book I had long, long ago, a book on QuickBasic by Gary Cornell. He was a professor of mathematics at the University of Connecticut. I later got a book by him on Java. His books are always full of interesting quotes and advice on programming in general.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 24253
                  • 125 Posts
                  Guess what?

                  When I disable the error handler, that is, when I not _install_ the error handler, the "connection to host lost" are gone.

                  At least, thats what I think it looks like. You never know you know ;-)

                  I’m almost sure I tried this before, but maybe I’m wrong.

                  So, somehow the excesive phpError calls are killing the server at my hosting provider :-(

                  Time to fix those hehe :-P

                  Greetz,

                  Remon
                    • 28580
                    • 24 Posts
                    I’ve just experienced a very similar problem where, for historical reasons, I am having to include .asp pages. If the asp server (IIS) returned a 404 or 500 error then for some reason the apache service was stopped and would not automatically restart as it appeared to have been sent a legitimate stop command rather than an unrecoverable error.

                    My solution was to prefix all the include statements in my code with @ and then modify the custom error handler function phpError in manager/document.parser.class.inc.php as follows


                        function phpError($nr, $text, $file, $line) {
                        	if ( $errno == E_WARNING && error_reporting() !=0) {//stepehnn mod additional code to force the ignore errors @ prefix to be respected
                    			if ($nr == 0 || ($nr == 8 && $this->stopOnNotice == false)) {
                    				return true;
                    			}
                    			if (is_readable($file)) {
                    				$source= file($file);
                    				$source= htmlspecialchars($source[$line -1]);
                    			} else {
                    				$source= "";
                    			} //Error $nr in $file at $line: <div><code>$source</code></div>
                    			$this->messageQuit("PHP Parse Error", '', true, $nr, $file, $source, $text, $line);
                            }
                        }


                    this solution was based on previous comments in this thread. I’m afraid I still don’t understand the underlying issue here.
                    I’m running.

                    modx 0.9.6.1p2
                    php 5.2.6
                    apache 2.2
                    windows server 2003
                      • 33239
                      • 1 Posts
                      Hi, I have an reselling account with this http://www.goresellers.com/ site for all my personal website develop ,still now there is no problem for my sites, also this site provide a internet business opportunity ,you just visit for more details.