Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2015-03-25 12:08:37

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

I guess I have misunderstood your intentions, sorry. No, there will be no problem if you put all links in a form, but yes, then you delegate computers work to humans.

Actually, 2000 might be not such a big deal. Robert (wet) has written a plugin that can generate thousands of articles at once, for testing.

Offline

#17 2015-03-25 23:28:29

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 440
Website GitHub Twitter

Re: Performance Anxiety | custom_field loopiness

Thanks, I’ll try wet_lorem_ipsum – it looks to be what I need.

For the moment I’m using your etc_query solution (so much better than my hack) – it’ll act as a baseline for my performance testing, with Jukka’s solution there as a back-up if the server squeals.

Thanks all for introducing me to new depths of Textpattern. All very useful.

Offline

#18 2015-03-26 09:34:09

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

You can go with pure php, as here, it will be a little faster.

Offline

#19 2015-03-27 18:59:28

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

giz wrote #289333:

Can someone explain why I couldn’t just wrap ask_cache around my inefficient code? Not that I’ve ever used it before…

I come back to your question: because some visitor has to trigger cache updates, and he/she will have to wait while the inefficient code is processed. Now, why not to update aks_cache automatically, on each article post/save? Here is my proposal:

  1. Install aks_cache and check Reset cache if site was updated preference on aks_cache tab.
  2. Wrap your code in some long-living aks_cache block, with noreset="".
  3. Install and activate etc_ping (below), and fill etc_ping field in Advanced Preferences with one or several comma-separated URLs where your aks_cache block(s) is (are) visible.

Each time an article is saved/updated, etc_ping will connect to its URLs and trigger aks_cache update.

# Name: etc_ping v0.1 
# Type: Admin plugin
# 
# Author: 
# URL: 
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

YToxMTp7czo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dGNoKCcvXmh0dHBzPzovaScsICR1cmwp
KSAkdXJsID0gaHUubHRyaW0oJHVybCwgJy8nKTsNCgkJCWZpbGVfZ2V0X2NvbnRlbnRzKCR1
cmwpOw0KCQl9DQoJfQ0KfSI7czo0OiJ0eXBlIjtzOjE6IjQiO3M6NToib3JkZXIiO3M6MToi
NSI7czo1OiJmbGFncyI7czoxOiIyIjtzOjQ6ImhlbHAiO2I6MDtzOjM6Im1kNSI7czozMjoi
ZDhhN2VkYjc1ZDg3NTBmYWJlMDI5ZDgxODMyNGM4YmUiO30=

Devs: would be great if update_lastmod() fired a callback.

Update: now allows relative URLs (like index.php?id=1).

Last edited by etc (2015-05-11 20:17:58)

Offline

#20 2015-03-27 20:11:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Performance Anxiety | custom_field loopiness

etc wrote #289510:

would be great if update_lastmod() fired a callback.

Fabulous idea. Can you please raise a feature or submit a pull request and we’ll get it folded in.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#21 2015-03-27 20:17:29

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 440
Website GitHub Twitter

Re: Performance Anxiety | custom_field loopiness

Thank you Oleg: great stuff. I’ll give it a whirl and report back with how my performance testing goes.

Offline

#22 2015-03-27 21:06:17

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

Bloke wrote #289511:

Fabulous idea. Can you please raise a feature or submit a pull request and we’ll get it folded in.

Thanks Stef, done. Would be even better if update_lastmod() were more verbose re the event triggering the update, but it makes 30 requests.

Offline

#23 2015-03-27 21:23:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Performance Anxiety | custom_field loopiness

etc wrote #289513:

Would be even better if update_lastmod() were more verbose re the event triggering the update

Thanks. If you have any ideas on callback name/event/step, by all means share them on the Issue page. We could raise a single one and you would have to use the $event to determine if it’s one you want to intercept, or maybe core could set the $step as the event for more granular options?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#24 2015-03-27 21:52:17

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

Something like this?

function update_lastmod($event = '', $rs = null) {
	...
//	$event will be $step, $rs contains article (image, ...) data passed by the caller
	callback_event('update_lastmod', $event, false, $rs);
}

This should be granular enough, but we can sleep on it for a while.

Edit: sorry for polluting the thread, maybe move it to Feature ideas?

Last edited by etc (2015-03-27 22:12:17)

Offline

#25 2015-04-10 21:08:37

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 440
Website GitHub Twitter

Re: Performance Anxiety | custom_field loopiness

etc wrote #289510:
  1. Install aks_cache and check Reset cache if site was updated preference on aks_cache tab.
  2. Wrap your code in some long-living aks_cache block, with noreset="".
  3. Install and activate etc_ping (below), and fill etc_ping field in Advanced Preferences with one or several comma-separated URLs where your aks_cache block(s) is (are) visible.

If my aks_cache code block appears on every page, what should I enter in etc_ping’s field in Advanced Preferences?

A minor issue: etc_ping’s preferences do not appear under 4.6dev. I know how to get around this!

Thank you.

Offline

#26 2015-04-10 21:21:50

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

giz wrote #289901:

If my aks_cache code block appears on every page, what should I enter in etc_ping’s field in Advanced Preferences?

Any page will do, if aks_cache blocks share the same id.

A minor issue: etc_ping’s preferences do not appear under 4.6dev. I know how to get around this!

Please share, I’m not (yet) very familiar with 4.6.

Offline

#27 2015-04-10 22:08:57

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 440
Website GitHub Twitter

Re: Performance Anxiety | custom_field loopiness

Thanks.

etc wrote #289902:

Please share, I’m not (yet) very familiar with 4.6.

Nothing spectacular: I’ve installed etc_ping on my 4.5.7 site, and plan on copying the relevant prefs over to my 4.6dev performance-testing installation, via phpmyadmin.

.

Or did you mean “explain the bug”? In my 4.6dev install there is no ‘advanced prefs’ tab – every preference (other than etc_ping) is shown in a large list, broken down by toggle-able sections. No mention of etc_ping in the source either. I hope this helps!

Last edited by giz (2015-04-10 22:15:34)

Offline

#28 2015-05-11 15:49:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,219
Website GitHub

Re: Performance Anxiety | custom_field loopiness

etc wrote #289510:

Now, why not to update aks_cache automatically, on each article post/save?

I’ve been adding a series of aks_cache blocks to a website and it makes a real difference, especially where tag use is intensive. But like you mention, the cache only persists for as long as the cache time (default = 60 mins) and has to be regenerated from scratch at intervals although nothing has changed. It could, however, conceivably remain cached until the next page update.

From your description, etc_ping sounds like it would be ideal, but I’m not sure if I understand the concept: am I right in assuming that when you save or post an article, etc_ping causes the pages listed in the etc_ping pref to be ‘visited invisibly’, causing aks_cache to refresh those cache blocks in that moment (rather than when the next person happens to call up that page)? In other words, you’re the one doing the ‘waiting’ before someone else has to.

I presume you then need to put http://www.domain.com/apples/,http://www.domain.com/oranges/,http://www.domain.com/category/fruit,… and so on in the pref, which can get quite long if you happen to have an extensive site (or can you do just /apples,/oranges,/category/fruit,…?).

Would it be possible to somehow refresh just certain aks_cache blocks, based on the article that is being saved, e.g. in the same section, or a designated section (occasionally I use sections to input data, but display it on another section)? Or would that not work, because any change to lastmod will cause aks_cache to dump its entire cache?

Finally, could the plugin be made to hook into some other event. I’m thinking of data brought in from a non-txp source, e.g. using your own etc_query?

Also, out of interest, what would you recommend as a long refresh interval: how large is a good large value: one month of minutes? one year of minutes?


TXP Builders – finely-crafted code, design and txp

Offline

#29 2015-05-11 17:50:29

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Performance Anxiety | custom_field loopiness

jakob wrote #290654:

From your description, etc_ping sounds like it would be ideal, but I’m not sure if I understand the concept: am I right in assuming that when you save or post an article, etc_ping causes the pages listed in the etc_ping pref to be ‘visited invisibly’, causing aks_cache to refresh those cache blocks in that moment (rather than when the next person happens to call up that page)? In other words, you’re the one doing the ‘waiting’ before someone else has to.

Yes, absolutely, etc_ping “visits” the supplied URLs on article updates, triggering aks_cache refresh (if present on the page).

I presume you then need to put http://www.domain.com/apples/,http://www.domain.com/oranges/,http://www.domain.com/category/fruit,… and so on in the pref, which can get quite long if you happen to have an extensive site (or can you do just /apples,/oranges,/category/fruit,…?).

Still yes, but it can be easily adapted to include “local” URLs.

Would it be possible to somehow refresh just certain aks_cache blocks, based on the article that is being saved, e.g. in the same section, or a designated section (occasionally I use sections to input data, but display it on another section)? Or would that not work, because any change to lastmod will cause aks_cache to dump its entire cache?

This could be done, though you are right, the blocks not updated by etc_ping will be updated (unless they are noreset) by the first visitor. One needs to modify aks_cache to fix this.

Finally, could the plugin be made to hook into some other event. I’m thinking of data brought in from a non-txp source, e.g. using your own etc_query?

I’ve raised an issue for other txp events, but haven’t thought of “custom” updates. Updates should not be triggered by visitors, otherwise there is no point in etc_ping, but etc_query is public-side… don’t know. You can wrap “external” data in <txp:aks_cache noreset="1" /> lasting, say, 59 minutes, and subscribe the appropriate pages to some free web monitoring service with 1h interval. But their synchronization is tricky.

Also, out of interest, what would you recommend as a long refresh interval: how large is a good large value: one month of minutes? one year of minutes?

After a week, txp sends the current date as Last-Modified (bug? feature?) even if nothing was modified, so more than one week seems pointless, but txp LastMod is not changed, so whatever you want.

Note: etc_ping will be pretty useless if you often update other things than articles, unless we subscribe it to more callbacks.

Last edited by etc (2015-05-11 20:38:05)

Offline

#30 2015-05-12 07:56:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,219
Website GitHub

Re: Performance Anxiety | custom_field loopiness

Thanks for the brilliant and informative reply! For sites that are only updated sporadically – perhaps a couple of blog articles a month etc. – then a cache update on article update would be fine, I think. The only real ‘problem’ is when making site changes, but after development that is less frequent.

I’m still unsure what the best caching strategies are, and whether txp-based or server-based is better (memcache?). I’d be interested in what people do or recommend. At present I do:

  • cache distinct chunks of a homepage built with txp-tags (anything that involves several db queries) using aks_cache
  • name chunk ids/blocks to be granular enough to cover all the different display situations (e.g. different active states on different pages), but common enough to avoid creating duplicate identical chunks (e.g. sidebar article menus per year not created for every article in that year).
  • not cached: straightforward txp:article output unless it brings in lots of associated data (e.g. image galleries, link lists, file downloads via custom fields).
  • not cached: information sourced from other sites that has its own update rhythm (e.g. twitter feed etc. – for that I’m using tweetledee for that which has its own caching).

Refresh just certain aks_cache blocks, based on the article that is being saved, e.g. in the same section, or a designated section … This could be done, though you are right, the blocks not updated by etc_ping will be updated (unless they are noreset) by the first visitor. One needs to modify aks_cache to fix this.

Agreed, aks_cache just dumps the entire cache at present.

Note: etc_ping will be pretty useless if you often update other things than articles, unless we subscribe it to more callbacks.

Do you mean things like files and images that might be automatically included in article output without needing to update the article? I guess those would need excluding from long-duration cached blocks or they would not appear.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB