Performance: revamp HS' cache system

Flying Drupalist - February 7, 2009 - 03:04
Project:Hierarchical Select
Version:6.x-3.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Issue tags:Performance
Description

Ajax is slow, I'm not sure if there's a model for preloading that I especially like, but some preloading is necessary I think.

#1

Wim Leers - February 7, 2009 - 12:00
Priority:normal» minor
Assigned to:Anonymous» Wim Leers
Status:active» postponed (maintainer needs more info)

I go a step further: client-side caching. See http://drupal.org/node/284638 and http://drupal.org/node/300572
HTML 5 client-side databases are already supported! Unfortunately, this has only been implemented in Safari/WebKit so far.

Also, AJAX isn't slow. It isn't very noticeable and definitely not annoying at http://wimleers.com/demo/hierarchical-select/taxonomy (there it takes about 0.5 second). So probably it's your server that's too slow … or you've got a huge taxonomy, in which case it might indeed be slow.
So, do you have a huge taxonomy?

#2

Flying Drupalist - February 7, 2009 - 16:25

My site has it at the same speed as yours, but when everything else happens instantaneously, and when my hierarchy is deep, even this little delay is annoying as heck and causes users to complain.

I do think there should be some kind of server-side precache, I know about the client side caching, but there should be more. {erhaps the tax should be cached on cron run, and only refreshed if a new term is added.

#3

Wim Leers - February 9, 2009 - 16:08
Assigned to:Wim Leers» Anonymous

Ah well, yes, you could create a server-side cache. I'd recommend altering the hs_taxonomy_hierarchical_select_children() function in the hs_taxonomy.module file and add caching in there. Then post the patch here and post the statistics of the improvements.

#4

Wim Leers - March 11, 2009 - 22:30
Status:postponed (maintainer needs more info)» closed

Closing while cleaning up the issue queue. Feel free to reopen.

#5

Flying Drupalist - July 17, 2009 - 04:04
Status:closed» active

I still can't do this, but I'm going to open it anyway.

I'm no longer sure if it makes sense to have a server side cache, I think even if it's based on cron it has possibilities for syncing poorly.

What makes most sense to me is selectable levels of preloading. So whenever a term is selected, the next 2 levels are ajax loaded as soon as initial loading is complete.

#6

Wim Leers - July 19, 2009 - 22:36
Status:active» postponed (maintainer needs more info)

That'll result in even worse performance. Suppose you have 15 items in the next level. You want to load the next 2 levels. That means 16 subtrees will have to be retrieved.

Client-side caching (as said, #284638: New cache system: JS and #300572: New cache system: Google Gears) make much more sense.

#7

Flying Drupalist - July 20, 2009 - 01:03

How would it impact performance? The page is already loaded. It'll just make future loading faster.

#8

Wim Leers - July 27, 2009 - 12:12
Title:Preload choices» Preload choices: revamp HS' cache system
Priority:minor» normal
Status:postponed (maintainer needs more info)» active

True. My wording was somewhat unfortunate. The loading of the page would take very, very long. But of course, you could use a server-side cache system as you suggested. But then the problem is the syncing with the client-side cache, as you also said. However, it's possible to work around that, by making the client-side cache system smarter.

Let's make this an umbrella issue :)

From my POV, the requirements are:
- We want to be able to have a server-side cache when the hierarchy is not too big.
- Each HS implementation must be able to tell the server-side cache when it should update a subtree.
- We want to be the client-side cache to update automatically whenever the server-side cache has been updated.
- The client-side cache must not be invalidated completely, each subtree must be updatable separately.

Comments?

#9

Flying Drupalist - July 28, 2009 - 04:31

Thanks for prioritizing this issue. :)

Your plans sound great. I hope it'll be enough to fix the speed issue though.

#10

Wim Leers - July 28, 2009 - 07:07
Title:Preload choices: revamp HS' cache system» Performance: revamp HS' cache system

Oh and what should happen first, is #528156: Performance: Remove Hierarchical Select's form cache and don't reconstruct the entire form anymore. Especially see http://drupal.org/node/528156#comment-1860876 in that issue.

#11

Wim Leers - July 29, 2009 - 20:05

This is a performance feature.

#12

Wim Leers - July 29, 2009 - 20:05
Status:active» postponed

And will not be for HS 3.0 for D6.

#13

Wim Leers - August 4, 2009 - 22:41

Instead of writing code for Client-side databases, Google Gears and whatnot, use jQuery jStore instead, which provides an abstraction for all of these: http://code.google.com/p/jquery-jstore/.

#14

Wim Leers - August 4, 2009 - 22:57

In addition to the explanation in #8:

Using a scheme like:
* invalidate the entire cache of a hierarchy if changes are made on the vocabulary settings page
* when a term is changed, invalidate the tree below it
* when a term is added, invalidate the tree above it

As mentioned in http://drupal.org/node/235932#comment-827377.

(Source: #253301: Client-side cache: more advanced cache invalidation.)

#15

Wim Leers - August 4, 2009 - 23:00

And JSON requests should be made cacheable (original issue: #228174: Make JSON requests cacheable).

 
 

Drupal is a registered trademark of Dries Buytaert.