[Vtigercrm-developers] performance and profiling

lajeesh k lajeeshk at gmail.com
Wed Oct 7 09:44:36 GMT 2015


function vtranslate  executed more than 1 lacks of time . its in detailview
 fetching one record. there might be some bad code


Regards,
Lajeesh

On Tue, Oct 6, 2015 at 3:13 PM, Conrado Maggi <comaggi at gmail.com> wrote:

> Hi,
>
> getPicklistValues is slow because is has to check for each picklist value
> whether the login users has access to it or not.
>
> Probably there is a way to cache that info. Since only changes when you
> update the picklist values.
>
> Cheers,
> Conrado
>
> On Tue, Oct 6, 2015 at 10:36 AM, lajeesh k <lajeeshk at gmail.com> wrote:
>
>> applied to_html changes, still detail view taking 20 seconds to load
>> page. summery view loading quickly
>>
>> I have used xdebud and webgrind for profiling. I am a newbie in profiling
>> while checking vtranslate function inside
>> Vtiger_Field_Model->getPicklistValues is one of the reason for this slownes
>> I have attached webgrind screenshot, it might help someone to identify
>> the bottleneck
>>
>>
>>
>>
>>
>> Regards,
>> Lajeesh
>>
>> On Mon, Oct 5, 2015 at 10:25 PM, lajeesh k <lajeeshk at gmail.com> wrote:
>>
>>> seems these suggestions from Alan is not included in vtiger 6.3.
>>> when i used xdebug profiling, this to_html function is called 226985
>>> times. calling this function increases as number of records increases
>>> I couldn't understand how to apply these changes by Alan and
>>> Sivakumar.if Anyone can provide these modified file for vtiger 6.3, then it
>>> will be really helpfull
>>>
>>>
>>>
>>> Regards,
>>> Lajeesh
>>>
>>> On Tue, Jul 22, 2014 at 6:23 PM, SivaKumar J <sivakumar.j at vtiger.com>
>>> wrote:
>>>
>>>> Hi Alan,
>>>>
>>>> Thank you very much for your contribution on to_html() function calls
>>>> to improve performance.
>>>> After analyzing to_html() function, we got that some of those checks
>>>> what we are checking in that are not required any more in Vtiger6.
>>>>
>>>> at line 366
>>>>
>>>>> *if($_REQUEST['module'] != 'Settings' && $_REQUEST['file'] !=
>>>>> 'ListView' && $_REQUEST['module'] != 'Portal' && $_REQUEST['module'] !=
>>>>> "Reports")// && $_REQUEST['module'] != 'Emails')*
>>>>> *        $ajax_action = $_REQUEST['module'].'Ajax';*
>>>>>
>>>> The above check is to identify whether the current request is AJAX or
>>>> not. If so, we are setting that as *$_REQUEST['module'].'Ajax'. *But,
>>>> there are not AJAX file in Vtiger6 in that structure. So, we don't need
>>>> this.
>>>>
>>>> at line 371
>>>>
>>>>> *if($action != 'CustomView' && $action != 'Export' && $action !=
>>>>> $ajax_action && $action != 'LeadConvertToEntities' && $action !=
>>>>> 'CreatePDF' && $action != 'ConvertAsFAQ' && $_REQUEST['module'] !=
>>>>> 'Dashboard' && $action != 'CreateSOPDF' && $action != 'SendPDFMail' &&
>>>>> (!isset($_REQUEST['submode'])) )*
>>>>> *    {*
>>>>> *        $doconvert = true;*
>>>>> *    }*
>>>>
>>>> In this check, except "Export"  we don't have any actions like what we
>>>> are comparing, so no need of this comparision. Earlier there is an action
>>>> called Export for Exporting record in Vtiger5.4.0, but now we are using
>>>> ExportData.php for this action. While Exporting record, at
>>>> *modules/Vtiger/actions/ExportData.php* we are sanitizing all values
>>>> which will decode those values with decode_html() on line 243. So, there is
>>>> no use of encoding with to_html() for Export as well. We can remove this
>>>> also. Else, we need to add this here and remove decode_html() where we are
>>>> doing in sanitize values.
>>>>
>>>>
>>>> After doing all these modification, finally my code is like this.
>>>>
>>>> */***
>>>>> * * Function to decide whether to_html should convert values or not
>>>>> for a request*
>>>>> * * @global type $doconvert*
>>>>> * * @global type $inUTF8*
>>>>> * * @global type $default_charset*
>>>>> * */*
>>>>> *function decide_to_html(){*
>>>>> *    global $doconvert,$inUTF8,$default_charset; *
>>>>> *     $action = $_REQUEST['action']; *
>>>>>
>>>>> *    $inUTF8 = (strtoupper($default_charset) == 'UTF-8'); *
>>>>>
>>>>> *    $doconvert = true; *
>>>>>
>>>>>
>>>>
>>>>    // Need to remove decode_html() which we are doing while exporting
>>>>> records from list/Detail view on  ExportData.php line 243
>>>>>
>>>> *  if($action == 'ExportData'){*
>>>>> *        $doconvert = false; *
>>>>> *    }*
>>>>> *}*
>>>>> // Execute this function when this file got included
>>>>> *decide_to_html();*
>>>>>
>>>>> */** Function to convert the given string to html*
>>>>> *  * @param $string -- string:: Type string*
>>>>> *  * @param $ecnode -- boolean:: Type boolean*
>>>>> *  * @returns $string -- string:: Type string*
>>>>> *  */*
>>>>> *function to_html($string, $encode=true) {*
>>>>> *    // For optimization - default_charset can be either upper / lower
>>>>> case.*
>>>>> *    global $doconvert,$inUTF8,$default_charset,$htmlCache;*
>>>>>
>>>>> *    if(is_string($string)) {*
>>>>> *        // In vtiger5 ajax request are treated specially and the data
>>>>> is encoded*
>>>>> *        if ($doconvert == true) {*
>>>>> *            if(isset($htmlCache[$string])){*
>>>>> *                $string = $htmlCache[$string];*
>>>>> *            }else{*
>>>>> *                if($inUTF8)*
>>>>> *                    $string = htmlentities($string, ENT_QUOTES,
>>>>> $default_charset);*
>>>>> *                else*
>>>>> *                    $string = preg_replace(array('/</', '/>/',
>>>>> '/"/'), array('<', '>', '"'), $string);*
>>>>>
>>>>> *                $htmlCache[$string] = $string;*
>>>>> *            }*
>>>>> *        }*
>>>>> *    }*
>>>>> *    return $string;*
>>>>> *}*
>>>>>
>>>>
>>>> Please let me know if I missed any thing in here.
>>>> Thank you
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Jul 18, 2014 at 6:34 PM, Alan Bell <alan.bell at libertus.co.uk>
>>>> wrote:
>>>>
>>>>> turns out that most of what to_html is processing is very repetitive,
>>>>> if it just populates an array as it goes along and then checks in that
>>>>> array it is a lot faster than doing htmlentities on the string every time.
>>>>>
>>>>> global $htmlcache;//store the stripped HTML as we go along, a lot of
>>>>> the time we are processing the same strings
>>>>> function to_html($string, $encode=true)
>>>>> {
>>>>>         global $doconvert;
>>>>>         global $default_charset;
>>>>>         global $htmlcache;
>>>>>         if($doconvert){
>>>>>                 if(isset($htmlcache[$string])){
>>>>>                     return $htmlcache[$string];
>>>>>                 }else{
>>>>>                     $clean= htmlentities($string, ENT_QUOTES,
>>>>> $default_charset);//we don't care if it is a string or not, faster not to
>>>>> care
>>>>>                     $htmlcache[$string]=$clean;
>>>>>                     return $clean;
>>>>>                 }
>>>>>         }else{
>>>>>                 return $string;
>>>>>         }
>>>>>
>>>>>
>>>>> }
>>>>>
>>>>> _______________________________________________
>>>>> http://www.vtiger.com/
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Siva
>>>> Vtiger
>>>>
>>>> _______________________________________________
>>>> http://www.vtiger.com/
>>>>
>>>
>>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20151007/7e0e6c9d/attachment-0001.html>


More information about the vtigercrm-developers mailing list