Textpattern CMS support forum

You are not logged in. Register | Login | Help

#791 2017-04-07 01:10:17

truist
Plugin Author
From: Ohio, USA
Registered: 2004-11-09
Posts: 256
Website

Re: tru_tags: A tagging plugin for textpattern

I’d like to help debug, but I don’t have the time available to spend trying out prerelease versions of textpattern and debugging issues. If 4.7 comes out, and has an issue, I’ll upgrade and try to fix it. Before that, though, is a bigger investment than I’m willing to make in this.

Offline

#792 2017-04-07 01:31:24

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,204
Website

Re: tru_tags: A tagging plugin for textpattern

truist wrote #305247:

I’d like to help debug, but I don’t have the time available to spend trying out prerelease versions of textpattern and debugging issues. If 4.7 comes out, and has an issue, I’ll upgrade and try to fix it. Before that, though, is a bigger investment than I’m willing to make in this.

That makes perfect sense. I mainly wanted to make sure you had a heads-up that there may be a problem when 4.7 is finalized – which is several months away at least.

Offline

#793 2017-04-13 16:37:20

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: tru_tags: A tagging plugin for textpattern

Thanks for keeping this really important plugin working!

Offline

#794 2017-07-18 13:22:42

spiridon
Member
From: Mariupol, Ukraine
Registered: 2011-01-30
Posts: 43
Website

Re: tru_tags: A tagging plugin for textpattern

I found out that tru_tags works rather slowly. Debug shows that:

*    42,02 |    28,56 | 	<txp:tru_tags_list showcounts="1" countwrapchars="()" />
     42,09 |     0,10 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     42,19 |          | 		[Rows: 11]
     42,26 |    10,46 | 		[SQL: SELECT Keywords FROM zl10n_txp_uk_ua as l10n_txp_uk_ua WHERE Keywords <> ''and Section != ''AND Section != 'tag' AND Section != 'archive' AND Section != 'search' AND Section != 'sitemap' AND Section != 'rss-feed' AND Section != 'contact' AND Section != 'copyright' AND Section != 'sources' AND Section != 'searchy' AND Section != 'help' AND Section != 'archives' and Status >= '4' and Posted <= now() and (now() <= Expires or Expires IS NULL) ]
     52,74 |          | 		[Rows: 275]
     56,47 |     0,15 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     56,63 |          | 		[Rows: 11]
     56,73 |    10,20 | 		[SQL: SELECT Keywords FROM zl10n_txp_uk_ua as l10n_txp_uk_ua WHERE Keywords <> ''and Section != ''AND Section != 'tag' AND Section != 'archive' AND Section != 'search' AND Section != 'sitemap' AND Section != 'rss-feed' AND Section != 'contact' AND Section != 'copyright' AND Section != 'sources' AND Section != 'searchy' AND Section != 'help' AND Section != 'archives' and Status >= '4' and Posted <= now() and (now() <= Expires or Expires IS NULL) ]
     66,95 |          | 		[Rows: 275]

You can see that the same queries are executed twice. And one of them is a heavy, noncached query.

The reason is that the function tru_tags_cloud_query() is called twice. I don’t know if it’s intended or it’s a mistake… But for myself I wrote a hack that fixes duplication of a heavy query.

Before:

<!-- Trace summary:
Runtime   : 80,45 ms
Query time: 39,53 ms
Queries   : 32
Memory (*): 2254 kB
-->

*    42,02 |    28,56 | 	<txp:tru_tags_list showcounts="1" countwrapchars="()" />
     42,09 |     0,10 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     42,19 |          | 		[Rows: 11]
     42,26 |    10,46 | 		[SQL: SELECT Keywords FROM zl10n_txp_uk_ua as l10n_txp_uk_ua WHERE Keywords <> ''and Section != ''AND Section != 'tag' AND Section != 'archive' AND Section != 'search' AND Section != 'sitemap' AND Section != 'rss-feed' AND Section != 'contact' AND Section != 'copyright' AND Section != 'sources' AND Section != 'searchy' AND Section != 'help' AND Section != 'archives' and Status >= '4' and Posted <= now() and (now() <= Expires or Expires IS NULL) ]
     52,74 |          | 		[Rows: 275]
     56,47 |     0,15 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     56,63 |          | 		[Rows: 11]
     56,73 |    10,20 | 		[SQL: SELECT Keywords FROM zl10n_txp_uk_ua as l10n_txp_uk_ua WHERE Keywords <> ''and Section != ''AND Section != 'tag' AND Section != 'archive' AND Section != 'search' AND Section != 'sitemap' AND Section != 'rss-feed' AND Section != 'contact' AND Section != 'copyright' AND Section != 'sources' AND Section != 'searchy' AND Section != 'help' AND Section != 'archives' and Status >= '4' and Posted <= now() and (now() <= Expires or Expires IS NULL) ]
     66,95 |          | 		[Rows: 275]

After:

<!-- Trace summary:
Runtime   : 69,91 ms
Query time: 28,87 ms
Queries   : 31
Memory (*): 2322 kB
-->


     36,10 |    18,57 | 	<txp:tru_tags_list showcounts="1" countwrapchars="()" />
     36,18 |     0,12 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     36,30 |          | 		[Rows: 11]
     36,37 |    11,05 | 		[SQL: SELECT Keywords FROM zl10n_txp_uk_ua as l10n_txp_uk_ua WHERE Keywords <> ''and Section != ''AND Section != 'tag' AND Section != 'archive' AND Section != 'search' AND Section != 'sitemap' AND Section != 'rss-feed' AND Section != 'contact' AND Section != 'copyright' AND Section != 'sources' AND Section != 'searchy' AND Section != 'help' AND Section != 'archives' and Status >= '4' and Posted <= now() and (now() <= Expires or Expires IS NULL) ]
     47,43 |          | 		[Rows: 275]
     51,07 |     0,14 | 		[SQL: SELECT name FROM ztxp_section as txp_section WHERE searchable != '1' ]
     51,21 |          | 		[Rows: 11]

Last edited by spiridon (2017-07-20 10:30:50)

Offline

#795 2017-07-18 16:32:04

truist
Plugin Author
From: Ohio, USA
Registered: 2004-11-09
Posts: 256
Website

Re: tru_tags: A tagging plugin for textpattern

Thank you for this!

tru_tags_cloud_query is called from a bunch of places; it’s how tru_tags figures out what tags exist. Depending on what you’re showing on a page, it could easily be called many times. It might also be the case that there’s a call tree where it’s being called redundantly; I’d have to know more about your site and the particular page you are testing, to guess.

But still, caching the query result does seem like a good idea, given how that function is used, and that it makes a heavy database call. But I am generally super-paranoid about any sort of caching; it usually leads to subtle bugs. (Like do we know if the $rs is just a list, or does it contain other state that might not be safe to cache? I don’t remember my php and textpattern well enough to be sure.)

Looking at your before and after, it looks like you only saved about 10ms (~13%) on the runtime – is that worth it? But of course, you saved about 25% on the query time, and if that query is used many times in a page, it might have a much bigger effect. Do you have any experimental results that would show that?

So on the whole, I think this is probably a good thing you’ve done. I looked over your code changes and I like them, except I think you should reuse $query_key on line 358. If you’d make that change and submit a PR, I’d happily merge it and publish a new version.

Thanks again!

Offline

#796 2017-07-20 10:30:19

spiridon
Member
From: Mariupol, Ukraine
Registered: 2011-01-30
Posts: 43
Website

Re: tru_tags: A tagging plugin for textpattern

truist wrote #306330:

tru_tags_cloud_query is called from a bunch of places; it’s how tru_tags figures out what tags exist.

I found that I had a call stack like this:

tru_tags_cloud() {
    tru_tags_list() {
        tru_tags_cloud_query()
        tru_tags_render_cloud() {
            tru_tags_tag_parameter() {
                tru_tags_cloud_query()
            }
        }
    }
}

But still, caching the query result does seem like a good idea, given how that function is used, and that it makes a heavy database call. But I am generally super-paranoid about any sort of caching; it usually leads to subtle bugs. (Like do we know if the $rs is just a list, or does it contain other state that might not be safe to cache? I don’t remember my php and textpattern well enough to be sure.)

This is not dangerous. The function safe_row always returns array (empty array in case of error).

Looking at your before and after, it looks like you only saved about 10ms (~13%) on the runtime – is that worth it? But of course, you saved about 25% on the query time, and if that query is used many times in a page, it might have a much bigger effect. Do you have any experimental results that would show that?

You can ignore it, but I can not.
I do not have any experimental results, except those that published earlier. I just found the inefficiency in the code.

If you’d make that change and submit a PR, I’d happily merge it and publish a new version.

Done.

Offline

#797 2017-07-20 12:11:31

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: tru_tags: A tagging plugin for textpattern

spiridon wrote #306323:

But for myself I wrote a hack that fixes duplication of a heavy query.

Note that in Txp 4.6+ you can significantly speed up queries with txp/php function now() This approach makes it possible to use mysql query_cache and in this case there is no need for additional caching.

Example usage (copy-paste from the plugin aks_article)

	// Using SQL caching capabilities. Txp 4.6+
	if (function_exists('now')) {
		$where_posted = now('posted');
		$where_expired = " AND (".now('expires')." <= Expires OR Expires IS NULL)";
	} else {
		$where_posted = "now()";
		$where_expired = " AND (now() <= Expires OR Expires = ".NULLDATETIME.")";
	}

	switch ($time) {
		case 'any':	$time = ""; break;
		case 'all':	$time = ""; $expired = 1; break;
		case 'future':	$time = " AND Posted > ".$where_posted; break;
		default:	$time = " AND Posted <= ".$where_posted;
	}
	if (!$expired) {
		$time .= $where_expired;
	}

Can adapt and add to the functions tru_tags_cloud_query and tru_tags_redo_article_search

Last edited by makss (2017-07-20 12:26:06)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#798 2017-07-20 13:23:19

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: tru_tags: A tagging plugin for textpattern

Please check my patch
Unfortunately, I can not check it on a real site.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#799 2017-07-20 14:48:28

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: tru_tags: A tagging plugin for textpattern

michaelkpate wrote #305227:

I am trying to get tru_tags 3.9 working on a site running 4.7 dev. I am constantly getting this error in the backend.

A problem occurred while loading the plugin: tru_tags -> User_Error: Table '[databasename].tru_tags_prefs' doesn't exist on line 409...

Perhaps fixed , please check.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#800 2017-07-20 17:21:18

spiridon
Member
From: Mariupol, Ukraine
Registered: 2011-01-30
Posts: 43
Website

Re: tru_tags: A tagging plugin for textpattern

makss wrote #306361:

Note that in Txp 4.6+ you can significantly speed up queries with txp/php function now() This approach makes it possible to use mysql query_cache and in this case there is no need for additional caching.

This will lead to malfunction of the plugin. And besides it fills caches with useless queries.

Offline

Board footer

Powered by FluxBB