Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2015-03-23 20:52:42

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

Re: Performance Anxiety | custom_field loopiness

Thank you all. I’m learning a lot from this thread already!

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

To give a little more context, I’m using wet_haystack to make my custom fields searchable. Are there likely to be any performance bottlenecks when searching i.e. when someone clicks on one of my “Use for” links?

Offline

#12 2015-03-23 21:09:15

etc
Developer
Registered: 2010-11-11
Posts: 3,199
Website

Re: Performance Anxiety | custom_field loopiness

giz wrote #289333:

Can someone explain why I couldn’t just wrap ask_cache around my inefficient code?

You could (and should), but optimize it anyway, to be kind with visitors who will trigger the cache updates.


etc_[ query | search | pagination | date | tree | cache ]

Offline

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

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 166
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: 3,199
Website

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.


etc_[ query | search | pagination | date | tree | cache ]

Offline

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

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 166
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: 3,199
Website

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.


etc_[ query | search | pagination | date | tree | cache ]

Offline

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

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 166
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: 3,199
Website

Re: Performance Anxiety | custom_field loopiness

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


etc_[ query | search | pagination | date | tree | cache ]

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 3,199
Website

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
Y19waW5nJywgJ2FydGljbGVfc2F2ZWQnKTsNCnJlZ2lzdGVyX2NhbGxiYWNrKCdldGNfcGlu
Z19pbnN0YWxsJywgJ3BsdWdpbl9saWZlY3ljbGUuZXRjX3BpbmcnKTsNCg0KZnVuY3Rpb24g
ZXRjX3BpbmdfaW5zdGFsbCgkZXZlbnQ9JycsICRzdGVwPScnKQ0Kew0KCWdsb2JhbCAkcHJl
ZnM7DQoJaWYoJHN0ZXAgPT0gJ2RlbGV0ZWQnKSB7DQoJCXNhZmVfZGVsZXRlKCd0eHBfcHJl
ZnMnLCAibmFtZSBMSUtFICdldGNcX3BpbmcnIik7DQoJfQ0KCWVsc2VpZigkc3RlcCA9PSAn
ZW5hYmxlZCcpIHsNCgkJaWYoIWdldF9wcmVmKCdldGNfcGluZycpKSBzZXRfcHJlZignZXRj
X3BpbmcnLCAkcHJlZnNbJ2V0Y19waW5nJ10gPSAnJywgJ2V0Y19waW5nJywgUFJFRl9BRFZB
TkNFRCwgJ2xvbmd0ZXh0X2lucHV0Jyk7DQoJfQ0KCXJldHVybjsNCn0NCg0KZnVuY3Rpb24g
ZXRjX3BpbmcoJGV2ZW50LCAkc3RlcCwgJHJzKSB7DQoJaWYoJHVybHMgPSBnZXRfcHJlZign
ZXRjX3BpbmcnKSkgew0KCQkkdXJscyA9IGRvX2xpc3QoJHVybHMpOw0KCQlmb3JlYWNoKCR1
cmxzIGFzICR1cmwpIHsNCgkJCWlmKCFwcmVnX21hdGNoKCcvXmh0dHBzPzovaScsICR1cmwp
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)


etc_[ query | search | pagination | date | tree | cache ]

Offline

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,674
Website

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

Board footer

Powered by FluxBB