Welcome Guest, Not a member yet? Register   Sign In
Never ending testing ENVIRONMENT
#1

Can we get rid  of some 'ENVIRONMENT ' things  in the core ? 24  +4 debugger
Production means PRODUCTION  so no more  checking  ENVIRONMENT   inside core
PHP Code:
    if (ENVIRONMENT !== 'testing')
        {
            if (
ob_get_level() > 0)
            {
                
ob_end_flush();
            }
        }
        else
        {
            
// When testing, one is for phpunit, another is for test case.
            
if (ob_get_level() > 2)
            {
                
ob_end_flush();
            }
        } 

quote [b]ciadmin [/b] 'Spark is long dead. Check the date of the tutorials that mention it.' 
https://forum.codeigniter.com/thread-651...#pid331775
no Spark check in production 
PHP Code:
// Never run filters when running through Spark cli
        if (! defined('SPARKED'))
        {
            $possibleRedirect $filters->run($uri'before');
            if ($possibleRedirect instanceof RedirectResponse)
            {
                return $possibleRedirect->send();
            }
            // If a Response instance is returned, the Response will be sent back to the client and script execution will stop
            if ($possibleRedirect instanceof ResponseInterface)
            {
                return $possibleRedirect->send();
            }
        }

// Never run filters when running through Spark cli
        
if (! defined('SPARKED'))
        {
            
$filters->setResponse($this->response);
            
// Run "after" filters
            
$response $filters->run($uri'after');
        }
        else
        {
            
$response $this->response;
        } 
no benckmark in Production
PHP Code:
    //    $this->benchmark->stop('controller_constructor');
        //    $this->benchmark->stop('controller'); 

is_cli() is needed by my website ? NO  but 17 is_cli() switch is performed
checks
PHP Code:
if (is_cli() && ! (ENVIRONMENT === 'testing'))
        {
            return 
md5($this->request->getPath());
        } 
So production = bool(false) ;
Reply
#2

(This post was last modified: 05-01-2019, 06:10 AM by dave friend.)

The reference to spark is not about the old package delivery system. It is about the custom CLI script that is part of CI4  https://codeigniter4.github.io/CodeIgnit...mands.html

There are many good reasons to run the framework from a command line ie. CRON jobs for one.
Reply
#3

Why whould you sacrifice 2-3-4-5-x years x 365 days of PRODUCTION website for 2 minutes usage of spark or cli commands ? Add a subdomain and do it from there . production means PRODUCTION with capital P. And lightning fast P ! Quote admin "You could always use a subdomain, eg http://www.yoursite.com and admin.yoursite.com, if you want to keep them separate." Means : if you want admin app you have to load 50-80 admin routes for every front end request with nested folders , module .. etc ..
We need a production version of ci4 where is no testing enviroment ,no developing , no spark no cli, and a developer (admin) version
Reply
#4

Any performance increases you would see if those were removed (which they won't be) would be unnoticeable.

One very important reason to have things working form the command line is running tests. And the new sparks CLI tool will only getter better and help you develop/debug faster in the future.

If your application is that speed critical in production, than I'm sure you've got opcache turned on, and are using multiple layers of caching as appropriate throughout the application, which will make many of those checks you're concerned about not ran anyway.
Reply
#5

(This post was last modified: 05-01-2019, 10:44 AM by tony.a.)

Removing all  references to cli and ENVIRONMENT switch  we have a gain of 40 - 100 ms /request no opcache .

Attached Files Thumbnail(s)
           
Reply
#6

(05-01-2019, 10:38 AM)tony.a Wrote: Removing all  references to cli and ENVIRONMENT switch  we have a gain of 40 - 100 ms /request no opcache .

Perhaps. But if you're running production without opcache you're making a mistake. Besides, you can't run something once and get a valid statistic.

Additionally, the loss of features in the framework isn't worth it. Sorry. Some of those are there to provide CLI tools usage, and some are there we can test it, which we won't give up.

And finally - any production server hardware should way outperform the numbers you're showing there. And lots of variables like the server you're running under (Apache has never been the speediest, for example), the configuration of the server, etc. For example, running locally on my 2015 Macbook Pro with the built in PHP server I see a total time for a raw install of 7-11ms. Every decent server I've hosted on in the last couple of years would easily outperform this.

So, while those aren't going away, we're always open to optimizations that don't come at the expense of the framework itself.
Reply
#7

I mean 30% of routing time(no opcache)  is switching  Enviroment and checking if is cli . 
Imagine yourself   a big boys script (facebook,etc )  checking  17 times (if Enviroment == testing) in production  website . For those coming from another script  might seems odd !
Reply
#8

At least a branch where there is none of those
Reply




Theme © iAndrew 2016 - Forum software by © MyBB