NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
DBG and CLI + what is expected performance impact?


Joined: 31 May 2017
Posts: 57
Reply with quote
Hello,
as far as I know it's not possible to debug/profile scripts run from CLI - is this still the case?

Moreover: is there any impact in having debugger.enabled=on, debugger.profiler_enabled=on for scripts that run in CLI? or there is no DBG performance impact for scripts running from CLI?

In case a debug/profile session is NOT started and DBG is loaded and enabled, is there any performance penalty on the performance of the web pages delivered by php?

Tnx
View user's profileFind all posts by blacktekSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Debug and profile from CLI is still possible There are two ways -- you can either run your script with DBGSESSID variable either in environment or in command line, or you can do this right in the IDE. See Run->CLI (console) to set CLI mode.
Impact depends on what your script is doing. If it is IO-bound, like DB reader/writer or network socket reader/writer, debugger impact is negligible. If it is CPU bound _and_ performs many function calls in tight loops, debugger impact can be measurable as, like for instance 5%. It's because debugger has to track what php is doing to be able to start right-away when DebugBreak() function is called, and it is tracking when it is just loaded and enabled.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 31 May 2017
Posts: 57
Reply with quote
Tnx for explanactions.

How can I set DBGSESSID in command line? Is it enough I pass it as an argument to the script run from Cli? Could you please provide an example?

Is there any impact on performance when dbg extension loaded and profiler / debugger disabled from php.ini?
View user's profileFind all posts by blacktekSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
example with environment:
$ DBGSESSID="1@mydesktopip:7869;d=1" myscript.php

example with command line argument:
$ myscript.php DBGSESSID="1@mydesktopip:7869;d=1"

http://forum.nusphere.com/faq-what-is-dbgsessid-syntax-t586.html
http://www.nusphere.com/kb/technicalfaq/faq_dbg_related.htm

regarding your 2nd question, debugger is completely deactivated if disabled

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 31 May 2017
Posts: 57
Reply with quote
Thank you for both answers. I made the second question just because if I do php - v with debugger disabled I still see the dbg fingerprint in the output but probably it just means that was loaded. Good that it doesn't create load. This way I can set disabled as default setting and I enable it in php-fpm. This way is disabled in CLI and enabled via web.

I'll follow the two links you kindly provided.

Thank you for you excellent support.
View user's profileFind all posts by blacktekSend private message


Joined: 31 May 2017
Posts: 57
Reply with quote
Hi Dmitri,
I've a small request for a new feature.

To avoid putting and remembering the long debugger string at command line (BGSESSID="1@mydesktopip:7869;d=1") we could put it in a php.ini variable and only use BGSESSID as parameter when running the script. If we put the full current version you use the command line information, while if we put only the short version you take the other settings from php.ini

Don't know if you like.
View user's profileFind all posts by blacktekSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
it wouldn't work for teams

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 31 May 2017
Posts: 57
Reply with quote
You're correct. Teams could continue to use current mode. It's just a shortcut for indivudals
View user's profileFind all posts by blacktekSend private message


Joined: 31 May 2017
Posts: 57
Reply with quote
extra clarification: if debugger and profiler are enabled is there any impact of performance if a debug/profile session is not started?
View user's profileFind all posts by blacktekSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
extra clarification: impact in real systems is almost always negligible like 0.00007%. In case if your script does not read any data from sources like databases, key-values, or any other files, and produces no output, and performs only function calls, impact is the highest but nevertheless it would around several percents.
extra clarification: yes, even if debug or profile session hasn't started, debugger still takes some CPU cycles to track execution context. You can call DebugBreak anywhere in your code, right? Debugger should be able to run from this point, so the context should be valid, that's why tracking is needed. Again, it's highly optimized code, it's amortized and impact is negligible.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 31 May 2017
Posts: 57
Reply with quote
thank you Dmitri, very detailed answer.
View user's profileFind all posts by blacktekSend private message
DBG and CLI + what is expected performance impact?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic