-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add SQL queries profiler in Debug zone with backtrace of call and EXPLAIN hovers #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e with backtrace of call and EXPLAIN hovers
…are visible same time
|
Is there any specific reason why you store two values of microtime() instead of just using local variable and storing the difference? |
|
Yes, it is for also displaying the delay between 2 queries: That allows to see the time taken to fetch the data from the previous query and to handle it in PHP. Btw, I'm continuing work on this to add the very detailed profiling information for each query: That way there will be no reasons to copy-paste the query into PhpMyAdmin to see the internal MySQL profiling, and that will win additional time in analysis. Also highlighted NULL keys, so it's immediately visible which parts run without using indexes. So please wait for my next commit and next comment here before testing and accepting pull request. |
|
Very cool. Side note: Ordering of the stuff under Profile Information would be good to have flipped too. So afterRender is at the top of the list. |
…y adding disconnect-handler, fine-tunned output for CSS, added highlighting of problems in keys and execution times
|
Ok, added visual indications for problems and time-hoggers (color-based). Sorting is not really needed with the visible red-on-yellow color-indications. Improvements as always welcome with pull request now here, or later on CMS. I'm considering now this pull request final for now. It is already a much better output for SQL optimizations than in any other CMS I know of. |
|
Just to complete the instructions:
|
|
There is a fix for that here: #1239 |
|
@beat Could you take a look at this branch? https://github.com/nonumber/joomla-cms/tree/debug Changed output. Bootstrapped it a bit and added a nice visual bar thing: |
|
@roland-d, Regarding styling of tooltips: Please feel free to contribute improvements. I have looked at styling them the best I could, however without any specific class for that dynamically added div at end of body by the tooltip code it looks like not possible to style them specifically to the debug module tooltips. E.g. the tooltip itself is fixed 200px max-width and can't be changed, it also has that oppacity of 0.8 that doesn't look great. The way I found to get rid of the 200px width is to CSS-float the div inside the tooltip. the very small black rectangle at top is the remaining part of the tooltip. Also make sure to clear your cache before testing, as the debug.css file is changed by this patch and Joomla doesn't have a "?r=revisionXYZ" differenciator to make sure caches do not stay with new releases. Also debug module executes at very of the php lifetime. Actually even after the mysql database is disconnected by the destructor of JDatabaseDriver called by PHP ending! So it is way too late to add javascript into the header. I'm also reluctant to add debug-specific Javascript to the document head or end of body too, as we want the debug ON behavior to be as near as possible from the normal one. That's also why I do EXPLAIN and SHOW PROFILE statements in a new database disconnectHandler at very end of PHP execution, to not change the execution timing and behavior of the rest of the page. I believe that for the backtrace popup, we can live with it for a few weeks/months, before the tooltip is changed from Mootools to jQuery. @nonumber, 👍 Please make a pull-request towards my branch beat:mysqlprofiling so I can review diffs and merge into the existing pull-request to joomla:master. |
|
@beat can't seem to be able to PR towards your branch :S PS: Can you merge your branch with latest J master? It seems to be behind a bit... |
|
@beat: Functional wise it is good, I see all the info in tables. Just a little hard to read at the moment. I will see what I can do about the styling. I just wasn't sure if this was supposed to look like. Maybe you already added some cool styling and if I would change it, it would be useless ;) Peter's addition looks finger licking good ;) |
|
Maybe good to have the EXPLAIN and other stuff in sliders or tabs instead of in tooltips... |
|
This looks awesome. Seems like Joomla! is finally reaching the pro league ;) One small remark about the file links: I already implemented the "xdebug:// protocol" that is set using the php.ini., and does basically the same as the "editor:// protocol". Another idea that came to my mind is using the logger to pass the information to the plugin (or whoever set the logger), so it doesn't have to be stored in the internal log of the database driver. Also I've implemented it with tabs instead of tooltips. Seems that I'm getting old or I need some new glasses, because the tooltips are way to small 👅 Excellent work 👍 |
|
@elkuku : Great find, I'm fine with myide://%f@%l @nonumber : Tabs are not loaded by default on most pages, to the contrary of tooltips, and tabs are not suitable here, as when analyzing you want to look at same time at EXPLAIN and at query, otherwise it's not understandable. I believe we can tweak a bit more the table's CSS to make it less tall (if last column doesn't wrap it would do it). @nonumber and others with improvement proposals: Please fork my fork, then change only the files changed and do pull request towards my mysqlprofiling branch, so I can merge them. @elkuku : The logger arrays don't eat space when not used, and when used they eat the same space. Keep in mind that there is normally only one JDatabaseDriver instance. Also the log and Disconnect handler could be useful for other applications (e.g. to make sure that session handler gets always the chance to store the session before database is closed ;-) ). |
|
@beat It is not possible to simply fork a fork. And like stated earlier, the other methods of creating a PR towards your branch fail. |
|
@nonumber wierd. A year back @elkuku added a pull request to my other fork here https://github.com/joomla/joomla-platform/pull/736/commits (but it was the "master" branch of the fork)... That's why I thought it was possible here too. You can attach here a patch file as well (hm :-D no attach function here either, looks like GitHub lacks features that GitLabs (open-source!) has LOL. You can email or skype me a patch file (my mail is my username here "at" our website). That should work :-) |
|
Easiest to just copy/paste code from: https://github.com/nonumber/joomla-cms/blob/debug/plugins/system/debug/debug.php |
|
Well, I believe the easiest way to do stuff like this is communication. Example:
(Note: the last link is written as Now what @beat does (if he has the time and will to do so) is just adding @nonumber as a new remote to his local clone. From here on @beat uses his favorite git tool to examine @nonumber's repo and do whatever he feels apropiate. Now @beat pushes to his That would be it. (Note on the example: It might have been easier if @nonumber had added @beat's repo as a remote first, and then based his work off @beat's I admit that this process might seem a bit complicated and if you only have one contribution, a simple pull request would be much easier. Of course, this implies that all persons involved in this process "have time" - not like me right now - see ya ;) |
|
Oh - BTW..... this could be a nice example of a contribution of several persons. It would be really cool if our new tracker could reflect this in "some way", so everybody gets his/her credits. (I know that nobody cares, but yes they do..) |
|
Another BTW: I can't send a PR to beat either. Seems like GitHub limits the list to the most active repos or something like that... that's really bad :( |
|
@elkuku 👍
Did you mean by this of reading php.ini setting "xdebug.file_link_format" (how?) and then replace %f with the filename and %l with the line number in that string ? |
|
Sure, the setting is just read with ini_get() here: debug.php#L67 in the __construct() method and stored to the The debug plugn really needs refactoring as it is about to reach the 1k line limit ;) |
|
I've had that issue with sending PRS to @davidhurley and @andreatarr before, it was very mysterious but eventually magically resolved.. |
|
I have sent this support request to github: http://quick-markup.com/p/51b3112230d85 |
|
@nonumber The work was already done but go ahead. I won't touch anything anymore. |
Added click-to-anchor on bars. Added tooltips to bars. Added time and memory bars to Profile Information Changed html output of and added colored labels to Profile Information Changed html output of and added labels to Memory Usage
|
Tadaaa: beat#3 See live demo: http://ndev.nl/debug |
|
@nonumber 👍 Just seen demo, looks awesome! Commenting on the pull request. |
|
It's getting better and better. |
|
I think the actual query is something you always want to see. As that is what you are inspecting. So when viewing the Explain or Profile Info, you still want to see the specific query to see what it refers to and see if you can spot why the info in there is like it is. |
|
I agree with @nonumber :) : Queries should always stay visible. |
|
correct, bad idea. :( |
Changed time notation from seconds to ms.
…query time label)
|
Ok, I've now merged after review this new version and many improvements suggestions that @nonumber implemented brilliantly (Thank you) I'm now declaring this pull request feature-complete and tested by its authors. Warning: It has become a powerful tool to show that a page is slow-loading and to help pinpoint reasons for slow-loading pages :D So we are ready for final testing at tracker, so that it can be committed. |
|
Tested and commented on the tracker. All looks great :) |
…hat got changed by diff-tool
…dy merged pull request #3 from nonumber/debug
|
Updated branch (merged from latest joomla-cms/master), solving trivial conflicts (a variable has been renamed in some of the drivers in joomla-cms/master). |
|
The $sql to $query? :) That was my doing in a global database cleanup PR: #856 |
…language string, and added information of query memory and returned rows
|
Ok, as language tests had failed and new tests are required, I fixed those, and also added a handy display of size of database query result in memory and rows for each query. :-) Ready for final tests and review. |
Changed tooltip text to use tooltipText method (thanks @nonumber)
|
I believe that for PRs like this one, it would be nice if actually all commits would be included when merging. But well, it has been merged 👍 |



This implements FR #31087 (only active in debug-mode).
Pretty handy in improving SQL queries and database scheme for speed.
Made a quick hack for my JAB13 talk, and re-did it on my return trip from JAB13 cleanly.
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31087
Feel free to improve upon it by issuing pull requests on my fork (on my branch mysqlprofiling).