CMSB v3.76 Beta Released (Performance Optimizations)

13 posts by 2 authors in: Forums > CMS Builder
Last Post: 7 hours ago   (RSS)

I just ran a test and updated an existing test project, which went from 0.12 seconds on the welcome screen to 13.05 seconds. This is very slow. Every screen change now takes 13 seconds to load.

Although the ini files were converted to schema.php, the old infiles were not deleted. I manually deleted the ini files, but it did not impact the time.

No entries in the developer log to help troubleshoot.

I did find one thing, though. There were old sample data files in the schema directory that I manually deleted, which took 3 seconds off the load time. They existed in the old data/schema directory, which only took .12 seconds to load.

Browser Dev Tools does not show anything useful

Jeff Shields
yaadev.com

Hi Jeff, 

Thanks for the feedback; it's very useful.

We're looking into some issues where existing plugins might be causing some all the schema files to be re-checked and re-generated on each page view, which is slow.    I'll post here as soon as we have a fix.

If possible, can you try temporarily disabling all the plugins and see if it's still slow? 

Dave Edis - Senior Developer
interactivetools.com

You are correct; it is the plugins. I deleted them all; now it is only .01 seconds, as predicted.

Jeff Shields
yaadev.com

Okay, great, thanks for checking.  We'll work on a fix for the plugins issue.

Dave Edis - Senior Developer
interactivetools.com

Hi All, 

Thanks for all the quick feedback via forum and email.  We've released beta 2 here: 
https://interactivetools.com/download/

We've also released an updated Permalinks plugin that is optimized for this new version (click download beta here): 
https://interactivetools.com/plugins/permalinks/

Feel free to give it a try or read on for technical details... 

We've added a notice (visible to admins only) "Checking for database schema updates..." at the top of: CMS Setup > Database.  This is the program checking the schema files and making any needed MySQL updates.  We've previously automatically done this on the login screen, database menu, and when called by plugins that are updating files, but we're making it more obvious for admins.  

Also, when plugins add schemas it will display (for admins): Checking for database schema updates... (initiated by plugin_name.php:123). So, if you're seeing that more than once, you can check that plugin and line number to ensure the plugin isn't running unneeded database updates.  Some plugins (ours included) were running their setup code more frequently than they needed to.

We've also added a new plugin hook, "plugin_menu_init" to make it easy to run setup code on the plugin menu.  You can see some sample code from the latest permlinks here, which double-checks its setup on the plugin menu and when it's activated.  

// on plugin active, or plugin menu - ensure schema is created
addAction('plugin_activate', 'permalink_cms_onInstallCreateSchemas',  null, 1);
addAction('plugin_menu_init', 'permalink_cms_onInstallCreateSchemas',  null, 0);

Give it a try and let me know any questions or bugs you find!  Also, remember to check the before/after times on the homepage if you can and let us know!

Thanks!

Dave Edis - Senior Developer
interactivetools.com

My original problem with slow loading was traced to a data entry error in the Security settings login timeout.

#24 - Warning: A non-numeric value encountered
/Volumes/J/test/html/www/cmsb/lib/login_functions.php on line 21
https://test.yaa.test/cmsb/admin.php?menu=admin&action=security

I unintentionally had an extraneous character in the 'advanced'.'login_expiry_limit' => '30`', when I removed the extra tick, speeds were back to normal. It appears that the entry was not validated as a number.

Jeff Shields
yaadev.com

QUESTION: Does loadSchema include the '__menu_order.php' fields? I have plugins that detect 'menuHidden' => 1, as well as 'menuType'. Just wondering if I need to deal with this myself when I update my plugin.

Jeff Shields
yaadev.com

Hi Jeff, 

The menu order functionality in the schema system works as follows:

  • loadSchema() doesn't include or load the __menu_order.php fields
  • Your plugins that detect 'menuType' should continue to work as is
  • Your plugins that check for 'menuHidden' might need some fallback code as we only save that if it's set.  e.g., if (!empty($schema['menuHidden'])) { // won't error if it's undefined
  • While loadSchema() doesn't call or load that file, saveSchema() ensures SchemaMenuOrder::refreshCache() is called which regenerates __menu_order.php with any updates.
  • The __menu_order.php file is only used to generate the CMS menu and store the menu sort order

The main changes to be aware of:

  1. The system no longer saves blank value or default fields in schema files, making schemas much smaller
  2. When checking fields, you might need to provide fallback values: $schema['city']['fieldPrefix'] ?? ''
  3. Menu order is now stored in __menu_order rather than in the schema files
  4. Field order is now determined by schema file order rather than $fieldSchema['order'] fields

For the non-numeric value issue, I added a type cast "(int)" to force it to be an integer if that comes up for anyone in future: 

function loginExpirySeconds(): int {
    // get session expiry in seconds
    $limit      = (int) settings('advanced.login_expiry_limit');

This will prevent similar problems in the future by forcing the value to be an integer if it happens for anyone else in future.

Great feedback and questions.  Let me know if you encounter any other issues!

Dave Edis - Senior Developer
interactivetools.com

What would you suggest to get the schema for myTable i.e. loadSchema('myTable') and the menuHidden from __menu_order.php?  I see several ways this could be done, but what would be the best approach?

Jeff Shields
yaadev.com