badoo / liveprof-ui

An aggregator and web interface for Live Profiler
http://liveprof.org/
MIT License
126 stars 19 forks source link

How to aggregate via xhprof_samping_enable? #4

Closed Slach closed 5 years ago

Slach commented 5 years ago

Dear authors LiveProf, thanks you for your efforts I think use xhprof_enable() as default callstack tracing method have not enough accurancy and require much CPU resources

i realized some custom Liveprof usage via xhprof_sample_enable + xhprof_sample_disable

https://github.com/Slach/howto-sample-profiling-and-flamegraph/blob/master/php/fpm/conf.d/liveprof_sampling.php

it's work with much lower CPU usage and can used for every php request

but when Liveprof work fine, Liveprof-UI aggregate result which not macth what i see in database please see sql dump with details https://mega.nz/#!OIpCTCSa!xGfjWqBM55yDoA0yO5iSvpoKoISICC5TbYL4AAzD4g0

Could you explain me why some additional info from details (like SQL queries) haven't parsed?

Slach commented 5 years ago

Lot of my profile_data in detail table look like

{
  "main()==>load_default_textdomain==>determine_locale==>get_locale==>get_option==>wpdb::get_row==>wpdb::query==>wpdb::_do_query==>mysqli_query#SELECT option_value FROM wp_options WHERE option_name = \'WPLANG\' LIMIT 1": {
    "ct": 1,
    "wt": 13770
  },
  "main()==>wp==>WP::main==>WP::query_posts==>WP_Query::query==>WP_Query::get_posts==>_prime_post_caches==>update_post_caches==>update_object_term_cache==>wp_get_object_terms==>get_terms==>WP_Term_Query::query==>WP_Term_Query::get_terms==>wpdb::get_results": {
    "ct": 1,
    "wt": 19999
  }
}

it's true reason maybe?

shagtv commented 5 years ago

Hello, Yes, the problem is in the data format I added xhprof_sample support in badoo/liveprof 1.2.0 - data from xhprof_sample converts to xhprof data format. It should work fine.

Slach commented 5 years ago

could you reopen this issue?? i try your changes with following auto_prepend_file

<?php
include '/opt/liveprof/vendor/autoload.php';
$liveprof = \Badoo\LiveProfiler\LiveProfiler::getInstance();
$liveprof->setMode(\Badoo\LiveProfiler\LiveProfiler::MODE_DB)
    // optional, you can use environment variable LIVE_PROFILER_CONNECTION_URL
    ->setConnectionString('mysql://liveprof:liveprof@mysql:3306/liveprof?charset=utf8')
    ->setApp($_SERVER['HTTP_HOST'])->setLabel($_SERVER['REQUEST_URI'])
    //all scripts with same APP and LABEL will be profiled
    ->setDivider(1)
    //all scripts with ALL label will be profiled
    ->setTotalDivider(1);
$liveprof->useXhprofSample();
$liveprof->start();

collected mysql data here https://mega.nz/#!3dpxEIJJ!yRGXtlfLDcziS0FBBYpXPUmFnNBdAjiaAKz1x-ix91E

as i see most my collected data in detail table look like {"main()":{"ct":1,"wt":0}} but some not all

could you help me to solve bugs here? https://github.com/Slach/howto-sample-profiling-and-flamegraph/#php---wordpress---liveprof