Problem/Motivation
Column "path" is empty & in related #2335687: Show file size on admin/reports/xhprof (esp if path is missing) new size column is added
Proposed resolution
Save "path" (Request URI) in dump
Remaining tasks
Agree on implementation & commit
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 2354853-23.patch | 2.66 KB | qichanghai |
| #22 | 2354853-21.patch | 2.66 KB | dom. |
| #20 | 2354853-20.patch | 3.31 KB | andypost |
| #17 | 2354853-17.patch | 3.47 KB | andypost |
| #17 | 2354853-interdiff-11.txt | 2.73 KB | andypost |
Issue fork xhprof-2354853
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
lussolucaIn the D7 version only the mongodb storage shows the path of a profiled page (see #2335687: Show file size on admin/reports/xhprof (esp if path is missing)), in D8 version the storage is a straight port so here we also didn't have the path stored (and the showed).
We need to modify the way the profile is stored to be similar to the one used in Webprofiler (with an index file with metadata, such the path, the size, the timestamp, ...). If we all agreed on this implementation I can easily port the webprofiler code to the XHProf module.
Comment #2
xanoBumping this to major, because it's a terrible pain in the ass.
Why is it that only MongoDB shows the path?
Comment #3
lussolucaThe XHProf file format doesn't save the profiled page's path. To overcome to this behavior the MongoDb submodule (not ported to D8 yet) saves the page's path in a field of the document.
I've only ported the filesystem storage which saves only the XHProf file so the information about page's path is lost. We need to do something similar to the webprofiler module: an index.csv file which stores metadata about each XHProf file
Comment #4
q0rban commentedHere's a patch to get this working in D7.
Comment #5
q0rban commentedComment #6
lussolucaI don't know if altering the XHProf data file is the best solution for this issue, I prefer to have metadata informations in a separate location.
Comment #7
juampynr commentedPatch at #4 applies cleanly and works fine.
Comment #8
donquixote commentedI guess the downside would be that the files are no longer readable by other programs.. valid point.
The options, as I see it, are
I think the csv file is the preferable solution.
But let's not forget we will parse this file not just on the overview page, but also to display the meta information for a specific xhprof run, on admin/reports/xhprof/%. We don't want this file to become too long.
Maybe we should quickly discuss the case where more than one site dumps xhprof files into the /tmp directory.. should they all go into the same csv file? We could avoid this by having a site-specific uuid in the filename. Which is no longer unique if you copy the database.. so use a hash of DRUPAL_ROOT instead?
Comment #9
lussolucaIn Webprofiler, for example, we have an option (enabled by default) to clear al profiles on cache clear, we can do the same here.
Can we store the csv file into the Drupal filesystem (public:// or private://) so it is site specific?
Comment #10
donquixote commentedMaybe we also want to clear once it hits a specific number or file size..
The nice thing about /tmp is that the operating system does the housekeeping for us. And, I assume, a csv file in /tmp would be cleared at the same time as the log files.
But I am not fundamentally opposed to it, just mentioning.
And, we don't want to these files to be copied around on backup or deployment / migration.
There is a reason why we can specify a tmp location in Drupal's filesystem settings..
Unfortunately, people might simply put /tmp there, and then it is shared with other projects. But md5(DRUPAL_ROOT) should be fairly unique, or not?
Comment #11
andrewsizz commentedCreated patch for 8.x version
@lussoluca yes I agree that batter save this path data(metadata informations) in a separate location, but for me looks also not bad to have all data in one place.
So maybe someone need for now, it will be enough ;)
Comment #12
andrewsizz commentedComment #13
kdebisschop commented@AndrewsizZ looking at the patch in #11, it seems to me that it requires unserializing each profile in the storage directory each time the index page is viewed (unless the page itself is cached). Am I reading the logic correctly?
If I am reading that correctly, do you have any thoughts or experience on the performance cost of unserializing that many files ? They can get large enough that I'm not sure we can easily ignore the cost of passing all that data through the serializer and then in the run object returned to scanXHProfDir() only to get the request path. Am I wrong?
Was the idea of a CSV or other index file deemed unworkable?
Thanks for your thoughts (and your patch which was helpful in understanding the issue)
Comment #14
kdebisschop commentedI have been exploring the idea of a CSV file myself by playing with the D8 patch. Since one person may be examining the file while another process is altering it, I think there are possible concurrency issues. Those are the sorts of things that make me wonder a database table might be worth it.
I explored creating separate smaller tables that have only the path in their contents - it would reduce the size of the file contents that needed to be loaded, but the summary page would still need to open very one of those little files to get the path.
Would anyone be interested in looking at a patch for d8 that puts it in the database and creates a cron to clean up removed files on a regular basis?
Comment #15
humansky commentedComment #16
andypostthis no longer works
trailing whitespaces
there should be d8 method for that
Comment #17
andypostHere's a reroll with fixes
Comment #18
andypostThis could be very expensive to deserialize all runs to get its path
Comment #19
andypostComment #20
andypostre-roll
Comment #21
andypostI see 2 options to get rid of serialization - dbtable/sqlite or private dir with run meta, then for each meta file it will be easy to look for .xhprof related in /tmp
Comment #22
dom. commentedReworked the patch for latest 8.x-1.x branch
Comment #24
qichanghai commentedThe following error appears after apply patch #21 in Drupal 10.2.4, because Drupal 10 uses Symfony 6 and it changed the method name to
getMainRequest.A new patch is applied.
Comment #25
marcelovaniPatch #24 works, tested on Drupal 10.2.6. Please merge.
Comment #26
marcelovaniComment #27
andypostI think it should wait a bit to finish other compatibility issues
Comment #28
marcelovaniOnly issue I had with Drupal 10.2.6 was https://www.drupal.org/project/xhprof/issues/3330615.
Comment #29
marcelovaniBTW, there is a similar issue that should be possible to be closed too https://www.drupal.org/project/xhprof/issues/1758944