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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • CiviCRM edit contact is super slow
Pages: [1]

Author Topic: CiviCRM edit contact is super slow  (Read 2704 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
CiviCRM edit contact is super slow
April 14, 2011, 07:54:36 am
Hi,

Was at a customer that was complaining about the speed of editing a contact (more than 10 sec to get the edit screen loaded).

After having checked that apache/mysql... configuration is ok, did compare with sandbox and a local install.

http://sandbox.civicrm.org/en/civicrm/contact/add?reset=1&action=update&cid=102&context=search

And we are above 10s too.

The problem seems to be a design issue:
Beside loading the page (that's about 2sec, not fast but understandable) it:
1) make one ajax request per phone
2) make one ajax request per email
3) make one ajax request per site
4) make one ajax request for the name of the employer

Ajax is fun, but super expensive when abused. There is a limit on how many requests are sent to the same server in parallel, each of these additional requests cost more than a second, and because they aren't done in parallel (and tend to have to wait on the images/css/tinymce...) to get queued, it's delaying being able to use the page.

It' the case here. there isn't a single reason I can imagine of the 4) for instance. It's stored on the same table as the first and last name, why aren't we simply putting in the initial request result ?!?

I haven't looked at the related entities, but it will obviously be much cheaper to put them in the initial request too.

How complicated would it be put them in the main page directly? it would make editing a contact with several phones and emails twice faster.

X+





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

kylejaster

  • I’m new here
  • *
  • Posts: 13
  • Karma: 2
Re: CiviCRM edit contact is super slow
April 14, 2011, 08:20:58 am
took a look at this - looks like we're paying a pretty heavy price for loading the form asynchronously - is there a rationale for this? it's a form... we should try to load the full form on the first request, and then update individual elements as needed via ajax, i think.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CiviCRM edit contact is super slow
April 14, 2011, 08:52:36 am
Hi,

I'm not even convinced we need an ajax call to add a new phone/email. In principle, having a hidden html blob that is part of the initial page and that you copy should do the trick.

And then, there is quickForm, that will probably go all bananas because there is a new field and qfKey hasn't been updated or whatever crazy stuff it does.

Anyway, I think we should have as a rule that if something is loaded in 100% of the cases as an ajax request on the ready(), that's a bug and it should have been included in the initial page (can be as inline json, but part of the initial request, not a separate one)

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: CiviCRM edit contact is super slow
April 14, 2011, 12:48:35 pm
I also had a discussion recently with a client regarding slowness. They spend a lot of time on custom "tab" field group editing and there too, the main page loads, and then afterward, the fields load via AJAX...
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CiviCRM edit contact is super slow
April 14, 2011, 02:28:29 pm
Prior to the current ajax implementation we used to load ~2-3 hidden rows for fields for each of the data elements that can occur multiple times. The base form was pretty huge and we could only allow a fixed max # of instances of phone, email etc. The current implementation perhaps went too far the other way and we should consider loading at least 1 instance of each enabled item on create and loading all the instances that have data on edit.
Protect your investment in CiviCRM by  becoming a Member!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CiviCRM edit contact is super slow
April 14, 2011, 02:32:29 pm
Hi,
What is the issue of loading them all directly?
can't be worse than loading them all one by one asynchronous, can it?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CiviCRM edit contact is super slow
April 14, 2011, 02:37:17 pm
Can't load the "all" since there's an unlimited number of instances allowed. :-)
Protect your investment in CiviCRM by  becoming a Member!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CiviCRM edit contact is super slow
April 14, 2011, 04:04:10 pm
But you find better to load them one by one doing an unlimited number of ajax calls ? :)

Seriously, pretty sure the difference of speed between loading on the first form 1 or 20 emails is negligible.

@kylejaster, is there a jquery template engine that you prefer ? I would like to do it so
1) you use
assign ('emails')->civicrm_api("email","Get", array(contact_id=>current contact id));

2) in the template
<script>
var emails={emails|json_encode};

3) have a template for the <section><label><input...>

3) use a jquery template engine to add on the form all the input fields for the emails

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

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CiviCRM edit contact is super slow
April 14, 2011, 04:53:59 pm
Quote from: xavier on April 14, 2011, 04:04:10 pm
But you find better to load them one by one doing an unlimited number of ajax calls ? :)

Seriously, pretty sure the difference of speed between loading on the first form 1 or 20 emails is negligible.
X+

I have no idea what's better. I was just saying that there currently isn't a limit on how many of each of this can be used. It probably does makes sense to preload "N" and only use separate subsequent calls when folks need N+. (Keeping in mind that for some larger chunks like the Address block we might want to keep N pretty small.)
Protect your investment in CiviCRM by  becoming a Member!

dalin

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 8
  • CiviCRM version: many
  • CMS version: Drupal 6
  • MySQL version: 5.0
  • PHP version: 5.2
Re: CiviCRM edit contact is super slow
April 14, 2011, 04:58:19 pm
Actually the browsers should be executing the AJAX requests in parallel, that's the [A]synchronous part.  IE7 can make 2 HTTP requests per host at one time, better browsers do 6. 

One simple way to improve things would be not to wait for document.ready().  If the DOM elements exist that need to be inserted into, then the JS can be executed immediately.  So by sticking the JS at the bottom of the appropriate template file, not wrapped in document.ready() can speed things up. 
--
Dave Hansen-Lange
Web Developer
Advomatic LLC
http://advomatic.com
Hong Kong office

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CiviCRM edit contact is super slow
April 26, 2011, 02:38:15 am
Hi,

Filled an issue: http://issues.civicrm.org/jira/browse/CRM-7973

I don't think requesting each related item as a separate ajax call has any benefit over putting them directly in the page, no matter where you start the requests. The problem is almost uniquely the request, not the place you fire it.

Each ajax request takes around 2 seconds to complete. if you have 10 emails+phone+websites, they won't be fired all in parallel, and they will also compete with other resources (css, js, images) that the browser is trying to download (according to my firebug).

Again, editing is more than 10 sec to be ready, mostly due to that. That's probably less accessible, doesn't save a lot of weight on the initial page, and is more resource intensive on the server.

Dave, even if you have more than N, you'll be faster to load all the N directly. Checking with the API, fetching 2 or 20 takes about the same time.

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • CiviCRM edit contact is super slow

This forum was archived on 2017-11-26.