Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-03-24 19:49:22

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

Re: Performance Anxiety | custom_field loopiness

Thanks, will do. I’ve never hit a performance problem in TXP before, but then I’ve never developed a site with more than 500 articles…

In light of all your comments, it looks to me that I’m jumping through hoops to dynamically generate something that needn’t be. If I hard code the links e.g. <a href="?q=Ceiling">Ceiling</a> I’ll have a pain-in-the-ass workflow, but way more efficient code.

Of course, all of this is moot if searching across custom_fields using wet_haystack is slow with thousands of articles.

Offline

#14 2015-03-24 22:27:12

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

Re: Performance Anxiety | custom_field loopiness

giz wrote #289355:

If I hard code the links e.g. <a href="?q=Ceiling">Ceiling</a> I’ll have a pain-in-the-ass workflow, but way more efficient code.

Of course, all of this is moot if searching across custom_fields using wet_haystack is slow with thousands of articles.

Hard-coding the links would make things just a little faster, since you still have to retrieve data and eliminate duplicates from thousands of articles. But doing this admin-side only when articles are updated, as proposed by Jukka (Gocom), would make this work invisible for site visitors. I’d rather put the results in a form, though.

Offline

#15 2015-03-25 01:46:58

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

Re: Performance Anxiety | custom_field loopiness

etc wrote #289356:

Hard-coding the links would make things just a little faster, since you still have to retrieve data and eliminate duplicates from thousands of articles.

By you still have to retrieve data I assume/hope you mean once the site visitor clicks on one of my hard-coded links? By hard-coding the links there would be no extra tag processing (other than calling the form they are in)…?

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 5,028
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
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

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,028
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,028
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:
# .....................................................................

YToxMTp7czo0OiJuYW1lIjtzOjg6ImV0Y19waW5nIjtzOjY6ImF1dGhvciI7czowOiIiO3M6
MTA6ImF1dGhvcl91cmkiO3M6MDoiIjtzOjc6InZlcnNpb24iO3M6MzoiMC4xIjtzOjExOiJk
ZXNjcmlwdGlvbiI7czowOiIiO3M6NDoiY29kZSI7czo3MzU6InJlZ2lzdGVyX2NhbGxiYWNr
KCdldGNfcGluZycsICdhcnRpY2xlX3Bvc3RlZCcpOw0KcmVnaXN0ZXJfY2FsbGJhY2soJ2V0
Y19waW5nJywgJ2FydGlj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UiO30=

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: 11,250
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.

Txp Builders – finely-crafted code, design and Txp

Offline

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

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

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,028
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: 11,250
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.

Txp Builders – finely-crafted code, design and Txp

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 5,028
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

Board footer

Powered by FluxBB