CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • can't we just be ignorant English speakers?
Pages: [1] 2

Author Topic: can't we just be ignorant English speakers?  (Read 2104 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
can't we just be ignorant English speakers?
July 12, 2011, 01:51:44 am
I just profiled a couple of pages & found that 20% & 40% of the 2 pages I profiled was spent on the crm_translate function. I probably picked pages that were intensive in this function (campaign interview & contribution search - both multi-row functions)

But it strikes me that for single language websites doing no translation having 20% of page load time go into translating seems a bit of a waste. Would it be too ignorant to suggest having a constant that we could define that would cause the ts function to exit early?

Attached is the profile pic (just one I couldn't seem to load more)

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: can't we just be ignorant English speakers?
July 12, 2011, 05:16:20 am

can you use a custom translation function which does nothing and see the speedup? You can set this custom function from the settings screen

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: can't we just be ignorant English speakers?
July 12, 2011, 05:43:54 am
Hi,

Harmut made a couple of comments about gettext on IRC, don't know if he followed it up with you. From memory, gettext was loading more stuff than necessary and the api was loading translation even so they aren't any UI to translate.

Try to catch him on IRC, he's likely to have more details ;)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 02:55:03 am
I stuck this in civicrm_module & called it & the page load time reduced by 9 seconds from 23 to 14.

function crm_no_translate($text, $params = array()){
        if (count($params)) {
            $text = strarg($text, $params);
        }
  return $text;
}

    function strarg(&$str)
    {
        $tr = array();
        $p = 0;
        for ($i = 1; $i < func_num_args(); $i++) {
            $arg = func_get_arg($i);
            if (is_array($arg)) {
                foreach ($arg as $aarg) {
                    $tr['%'.++$p] = $aarg;
                }
            } else {
                $tr['%'.++$p] = $arg;
            }
        }
        return strtr($str, $tr);
    }

 (note that the page, record interview, is particularly slow because it calls buildProfile 225 times - 5 fields * 45 contacts - even though pagination means only 10 are displayed. The 225 calls to buildProfile take 20 seconds without the above & 10 seconds with)
« Last Edit: July 13, 2011, 02:57:59 am by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 02:59:23 am
NB changing

CRM_Core_I18n::strarg($str)
 to

CRM_Core_I18n::strarg(&$str)


wouldn't hurt
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 03:06:18 am
NB from smarty

{$tsLocale}    "en_US"
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 04:35:32 am
Of the remaining 14 seconds :

4 secs are spent  running this query 225times (20 ms each)

SELECT v.name as name ,v.value as value, v.grouping as grouping FROM civicrm_option_value v, civicrm_option_group g WHERE v.option_group_id = g.id AND g.name = 'address_options' AND g.is_active = 1 AND v.is_active = 1 ORDER BY v.weight

1 is  spent running  this query 45 times for each of the 5 fields:
SELECT * FROM civicrm_custom_field WHERE ( civicrm_custom_field.id = 121 )

a bit less is spent running this query 45 times

SELECT v.label as label ,v.value as value, v.grouping as grouping FROM civicrm_option_value v, civicrm_option_group g WHERE v.option_group_id = g.id AND g.id = 110 AND v.is_active = 1 AND g.is_active = 1 ORDER BY v.weight, v.label;


I've attached a pic of what the profile looks like - ignore the percentages - but note that in CRM_Core_optionGroup::values - the cacheget doesn't seem to be working as the query above this is the one being called there over & over

« Last Edit: July 13, 2011, 05:04:55 am by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: can't we just be ignorant English speakers?
July 13, 2011, 05:28:38 am
Looks like some caching wouldn't hurt. I did notice as well some parts linked to profile dead slow (eg petition signature.

is there an easy way to see where these queries are generated in the code?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 05:59:02 am
If you look at that pic above there are 4 functions with the word 'value' in them showing. 3 of them are guilty for the queries I pasted above ...
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 01:39:32 pm
The biggest / most recurrent of the 3 queries seems to be

CRM_Core_OptionGroup::getValue() which has no caching


The third
CRM_Core_OptionGroup::values()

Has caching code but it doesn't seem to be working. Not sure I completely 'get' how it should work but nothing is being set in my cache table & it never returns early due to the caching
« Last Edit: July 13, 2011, 01:42:00 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 13, 2011, 01:44:38 pm
Perhaps this is a clue to why the caching isn't working - from another function - could the key be too long


        if ( strlen( $cacheKey ) > 40 ) {
            $cacheKey = md5( $cacheKey );
        }
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: can't we just be ignorant English speakers?
July 13, 2011, 10:35:52 pm
@civicore,

Code: [Select]
CRM_Core_OptionGroup::getValue() which has no caching
Can we replace  it with CRM_Core_OptionGroup::values() ?

Ie. assuming than if you get one value you are likely to get the others in the same group and on average, better to take a bit more than needed one once than exactly what you need 100th of time?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 14, 2011, 04:11:12 pm
Also - running pledge summary report - this query runs 32 times

SELECT v.label as label ,
v.value as value
FROM civicrm_option_value v, civicrm_option_group g WHERE v.option_group_id = g.id AND g.name = 'contribution_status'
AND g.is_active = 1
AND v.value = 2
AND v.is_active = 1

AND this one - 18 times

SELECT v.label as label ,v.value as value FROM civicrm_option_value v, civicrm_option_group g WHERE v.option_group_id = g.id AND g.name = 'contribution_status' AND g.is_active = 1
AND v.value = 6 AND v.is_active = 1

Probably an easier place to see them than the interview screen
« Last Edit: July 14, 2011, 04:12:54 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 14, 2011, 06:24:06 pm
I have logged this on the pledge summary issue

http://issues.civicrm.org/jira/browse/CRM-8501
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: can't we just be ignorant English speakers?
July 14, 2011, 07:14:10 pm
& this one on

http://issues.civicrm.org/jira/browse/CRM-8502

on

            $addressOptions = CRM_Core_BAO_Preferences::valueOptions( 'address_options' );

not being cached
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • can't we just be ignorant English speakers?

This forum was archived on 2017-11-26.