Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2015-07-16 11:57:20

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

Re: Option prefetch_forms() - preload all forms in a single query

makss wrote #293270:

To configure or checking the MySQL I would advise MySQLTuner
It shows the basic configuration errors, and will optimally allocate memory for buffers and cache.

There are forks MySQL, such as Percona or MarinaDB. They are fully compatible with MySQL, but more stable and they added some features. I use Percona.

Yes, your site is very fast indeed, but I’m not sure everybody has access to the server config. Your proposal can surely be useful for the happy few, why wouldn’t you rather write some aks_tweaks plugin?

Offline

#12 2015-07-16 12:47:17

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

Re: Option prefetch_forms() - preload all forms in a single query

etc wrote #293322:

Yes, your site is very fast indeed, but I’m not sure everybody has access to the server config. Your proposal can surely be useful for the happy few, why wouldn’t you rather write some aks_tweaks plugin?

I do not quite understand the question. To change the configuration of MySQL need root access to the server or vds. PHP plugin can not do this.

If you are using shared hosting and it is not configured MySQL query_cache, my advice – change shared hosting. If administrators hosting unable to set up one of the key things is scary to think what else could happen on such hosting. Now the price of hosting low and there is no problem with his choice.

Or did you mean to write a plugin that performs preload forms? I also can not do it without changing the core code, because I can not access the static variable $forms.


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

#13 2015-07-16 12:54:51

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

Re: Option prefetch_forms() - preload all forms in a single query

makss wrote #293330:

Or did you mean to write a plugin that performs preload forms? I also can not do it without changing the core code, because I can not access the static variable $forms.

Ah yes, it’s not global, sorry.

Offline

#14 2015-07-16 17:10:13

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: Option prefetch_forms() - preload all forms in a single query

makss wrote #293270:

There are forks MySQL, such as Percona or MarinaDB. They are fully compatible with MySQL, but more stable and they added some features. I use Percona.

+1 for Percona, it’s very good. It’s become part of my standard LAMP build deployment.

Offline

#15 2015-08-18 09:27:02

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,267
Website

Re: Option prefetch_forms() - preload all forms in a single query

Bloke wrote #284611:

Faced with this restriction we must either:

1) move the static variable out of the function to a global

-1. I’d rather refrain from exposing the private parts of the single function that should load forms to the public.

2) modify fetch_form() such that it retains backwards compatibility but enables multiple forms to be supplied as its argument.

+1. Testable, no side effects, a move in the right direction.

Would you propose a new tag?

I’d decide along that line: Tags are for designers, preferences are for administrators. This is not a decision the designer but the site administrator should have to make.

Offline

#16 2015-08-18 11:03:57

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

Re: Option prefetch_forms() - preload all forms in a single query

Bloke wrote #284611:

2) modify fetch_form() such that it retains backwards compatibility but enables multiple forms to be supplied as its argument.

Unfortunately, the additional arguments do not get to do it. But thank you for the right direction to find a solution.
It seems to me that with callback can be solved this problem by fully preserving compatibility with previous versions.

Example callback code has not yet been tested.

function fetch_form($name)
{
    static $forms = array();
    if (empty($forms) && has_handler('forms.prefetch')) {
        $return_forms = callback_event('forms.prefetch');
        if (is_array($return_forms)) {
            $forms = $return_forms;
        }
    }
... skip ...

What do you think about this decision?


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

#17 2015-08-18 11:11:13

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,267
Website

Re: Option prefetch_forms() - preload all forms in a single query

makss wrote #294188:

Unfortunately, the additional arguments do not get to do it.

You might want to try this:

$name could be an array of names, or even a wildcard like '*' (this would eventually affect people who chose to name a form *, though – we would have to protect them from shooting themselves in the foot).

These are conditions we could detect and act accordingly, couldn’t we?

Combined with a preference setting to enable form prefetches, the core can easily preload forms before the parsing phase even starts.

Offline

#18 2015-08-18 12:33:03

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Option prefetch_forms() - preload all forms in a single query

On a website which loads 7 or 8 forms on typical pages, I see each form takes around 0.1ms query time. You’d gain at most 0.7ms. However, total query time on those pages is 60-90ms. Why bother for such a small gain?

Offline

#19 2015-08-18 14:14:09

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

Re: Option prefetch_forms() - preload all forms in a single query

ruud wrote #294196:

On a website which loads 7 or 8 forms on typical pages, I see each form takes around 0.1ms query time. You’d gain at most 0.7ms. However, total query time on those pages is 60-90ms.

Time request form I have the same: 0.1-0.2 ms
Total query time on those pages is 2.3 – 11.5 ms

Sites are located on the VDS, in MySQL query_cache set.
Results for the second page request, ie, If possible, use query_cache.
Textpattern version 4.5.1. Unfortunately I have no working sites Textpattern 4.6, there is only a test site.

site 1
<!-- Runtime: 0,0237 --><!-- Query time: 0,004335 --><!-- Queries: 23 --><!-- Memory: 5995Kb, -->
site 2
<!-- Runtime: 0,0289 --><!-- Query time: 0,002322 --><!-- Queries: 19 --><!-- Memory: 3718Kb,  -->
<!-- Runtime: 0,0367 --><!-- Query time: 0,003123 --><!-- Queries: 20 --><!-- Memory: 3714Kb,  -->
site 3
<!-- Runtime: 0,0366 --><!-- Query time: 0,009450 --><!-- Queries: 17 --><!-- Memory: 3683Kb, -->
<!-- Runtime: 0,0352 --><!-- Query time: 0,005717 --><!-- Queries: 19 --><!-- Memory: 3691Kb, -->
<!-- Runtime: 0,0983 --><!-- Query time: 0,011531 --><!-- Queries: 14 --><!-- Memory: 3729Kb, -->
site 4
<!-- Runtime: 0,0302 --><!-- Query time: 0,003434 --><!-- Queries: 23 --><!-- Memory: 3985Kb, -->
<!-- Runtime: 0,0269 --><!-- Query time: 0,002985 --><!-- Queries: 21 --><!-- Memory: 3888Kb, -->

BTW, it may be necessary to create several types of sites(sql dump) with content “Lorem ipsum” to test and optimize performance?


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

#20 2015-08-18 14:35:27

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

Re: Option prefetch_forms() - preload all forms in a single query

wet wrote #294189:

$name could be an array of names, or even a wildcard like '*'
Combined with a preference setting to enable form prefetches, the core can easily preload forms before the parsing phase even starts.

As I understand it, in preference to need to add two fields:

1. Drop down list Enable preload form

  • None
  • All
  • Include only
  • Exclude only

2. Text field with form names or mask.
form1, my*, some*, form2


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

Board footer

Powered by FluxBB