Poor efficiency in IP.C with uncached components
#1
Posted 03 August 2012 - 11:24 PM
Currently IP.C does this when a block is set to "no cache".
1. Retrieve block data
2. Update block data
3. Execute this data.
4. Insert (or update on duplicate) into template cache.
Problem: Steps #2 & #4 are extremely inefficient as they're writes and pointless.
With just few bits of coding, I altered this behavior on my version so that it skips steps 2 & 4. It works and it skips two writes per block. With multiple blocks, this is a huge huge save in performance.
Problem originates from the fact that it doesn't differentiate between absent cache and zero cache. That is, when a cache is non-existent when it should vs when a cache should not be set. It treats the both equally, generating and saving the cache each time then returning the value when it should have only generated it and returned it.
- Marcher Technologies likes this
#2
Posted 29 September 2012 - 10:36 AM
I also don't like the way IP.C keeps UPDATE/INSERT blocks into the database which should be cached at all.
Running on Invision Power Board since 2003!
#3
Posted 29 September 2012 - 05:49 PM
#4
Posted 29 September 2012 - 06:19 PM
So a UPDATE/INSERT query to the database ( ccs_template_cache and ccs_template_blocks) is wasted resources because the block is different every time.
Running on Invision Power Board since 2003!
#5
Posted 01 October 2012 - 12:44 PM
- Alfa1 likes this
Developer / Senior Support
If it sounds like fun, it's not allowed on the bus!

Invision Power Services, Inc.
#6
Posted 20 October 2012 - 01:00 AM
We had removed the caching update/insert queries for those blocks in one release a while back and it cascaded a bunch of issues as a result. We will need to rewrite how the blocks are handled to remove the insert/update queries you are referring to for non-cached blocks. This is something I'm aware of.
*please* give it another shot soon....... even a flag on the source of plugin blocks that says the block is not cacheable that would not run this would help insanely.
UPDATE ccs_blocks SET block_cache_output='\r\n<h1 class='ipsType_pagetitle'>testssssss</h1>\r\n <div class='topic_controls'>\r\n <!--hook.if.skin_global.paginationTemplate.haspages.pre.startif--><!--hook.if.skin_global.paginationTemplate.haspages.post.startif--><div class='pagination clearfix left '>\n <ul class='ipsList_inline back left'>\n <!--hook.if.skin_global.paginationTemplate.firstpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.firstpage.pre.else--><!--hook.if.skin_global.paginationTemplate.firstpage.post.else--><!--hook.if.skin_global.paginationTemplate.firstpage.post.endif-->\n <!--hook.if.skin_global.paginationTemplate.prevpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.prevpage.pre.else--><!--hook.if.skin_global.paginationTemplate.prevpage.post.else--><!--hook.if.skin_global.paginationTemplate.prevpage.post.endif-->\n </ul>\n <ul class='ipsList_inline left pages'>\n <li class='pagejump clickable pj0321775001'>\n <a href='#'>Page 1 of 9 <!--<img src='http://p125180.ipscdn.com/public/style_images/master/dropdown.png' alt='+' />--></a>\n <script type='text/javascript'>\n ipb.global.registerPageJump( '0321775001', { url: \"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1<!--hook.if.skin_global.paginationTemplate.furlinfo.pre.startif--><!--hook.if.skin_global.paginationTemplate.furlinfo.pre.else--><!--hook.if.skin_global.paginationTemplate.furlinfo.post.else--><!--hook.if.skin_global.paginationTemplate.furlinfo.post.endif-->\", stKey: 'st', perPage: 1, totalPages: 9, anchor: '' } );\n </script>\n </li>\n <!--hook.if.skin_global.paginationTemplate.normalpages.pre.startif--><!--hook.if.skin_global.paginationTemplate.normalpages.post.startif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.outer.pre--><!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.post.startif-->\n <li class='page active'>1</li>\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.endif--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.pre.else--><li class='page'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=1\" title=\"<!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.startif--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.else-->2<!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.else--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.endif-->\">2</a></li><!--hook.if.skin_global.paginationTemplate.activepage.post.else--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.pre.else--><li class='page'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=2\" title=\"<!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.startif--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.else-->3<!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.else--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.endif-->\">3</a></li><!--hook.if.skin_global.paginationTemplate.activepage.post.else--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.outer.post--> <!--hook.if.skin_global.paginationTemplate.normalpages.pre.endif--><!--hook.if.skin_global.paginationTemplate.normalpages.post.endif-->\n </ul>\n <ul class='ipsList_inline forward left'>\n <!--hook.if.skin_global.paginationTemplate.nextpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.nextpage.post.startif-->\n <li class='next'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=1\" title=\" - Next page\" rel='next'>Next</a></li>\n <!--hook.if.skin_global.paginationTemplate.nextpage.pre.endif--><!--hook.if.skin_global.paginationTemplate.nextpage.post.endif-->\n <!--hook.if.skin_global.paginationTemplate.lastpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.lastpage.post.startif-->\n <li class='last'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=8\" title=\" - Go to last page\" rel='last'>»</a></li>\n <!--hook.if.skin_global.paginationTemplate.lastpage.pre.endif--><!--hook.if.skin_global.paginationTemplate.lastpage.post.endif-->\n </ul>\n </div><!--hook.if.skin_global.paginationTemplate.haspages.pre.endif--><!--hook.if.skin_global.paginationTemplate.haspages.post.endif-->\r\n </div>\r\n\r\n \r\n <div class='maintitle ipsFilterbar'>\r\n <ul class=\"ipsList_inline ipsType_small\">\r\n \r\n <li class=\"active\"><a href='http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc'>Recently Updated</a></li>\r\n <li class=\"\"><a href='http://localhost/index.php?/page/articles.html?sort_col=record_saved&sort_order=desc'>Date Added</a></li>\r\n <li class=\"\"><a href='http://localhost/index.php?/page/articles.html?sort_col=record_views&sort_order=desc'>Most Views</a></li>\r\n <li class=\"\"><a href='#cat_filter_menucontent' id='cat_filter'>Custom</a></li>\r\n \r\n </ul>\r\n </div>\r\n <div id='cat_filter_menucontent' class='ipbmenu_content ipsPad' style='display: none'>\r\n <form id='filter_form' action=\"http://localhost/index.php?/page/articles.html?&\" method=\"post\">\r\n <strong>Sort by</strong><br />\r\n <SELECT name='sort_col'>\r\n <option value='primary_id_field'>Article ID</option>\r\n <option value='member_id'>Member ID</option>\r\n <option value='record_saved'>Submission Date</option>\r\n <option value='record_updated' SELECTed='SELECTed'>Last Updated Date</option>\r\n <option value='rating_real'>Rating</option>\r\n <option value='record_views'>Views</option>\r\n \r\n <option value='field_1'>Title</option>\r\n \n\r\n \r\n \n\r\n \r\n \n\r\n \r\n \n\r\n \r\n \n </SELECT>\r\n <br /><br />\r\n <strong>Sort order</strong><br />\r\n <SELECT name='sort_order'>\r\n <option value='asc'>Ascending (A-Z)</option>\r\n <option value='desc' SELECTed='SELECTed'>Descending (Z-A)</option>\r\n </SELECT>\r\n <br /><br />\r\n <input type=\"submit\" value=\"Sort\" class=\"input_submit\" />\r\n </form>\r\n </div>\r\n <script type='text/javascript'>\r\n new ipb.Menu( $('cat_filter'), $('cat_filter_menucontent'), { stopClose: true } );\r\n </script>\r\n <div class='ipsBox'>\r\n <div class='ipsBox_container'>\r\n <table class='ipb_table topic_list hover_rows'>\r\n <tr>\r\n <th class='col_f_icon altrow short'> </th>\r\n \r\n \r\n <th>Title</th>\r\n \n\r\n <th>Teaser Paragraph</th>\r\n \n\r\n <th>Body</th>\r\n \n\r\n <th>Publish Date</th>\r\n \n\r\n <th>Article Image</th>\r\n \n \r\n </tr>\r\n \r\n <tr class='__topic unread'> \r\n <td class='col_f_icon altrow short'>\r\n <img src='http://p125180.ipscdn.com/public/style_images/master/t_unread_dot.png' alt='' /><br />\r\n </td>\r\n \r\n \r\n <td>\r\n \r\n \r\n <h4>\r\n \r\n <a href='http://localhost/index.php?/page/articles.html/categories/articles/forum/promoting-posts-to-articles-r1'>Promoting Posts to Articles</a>\r\n \r\n </h4>\r\n \r\n \r\n </td>\r\n \n\r\n <td>\r\n \r\n \r\n \r\n </td>\r\n \n\r\n <td>\r\n \r\n IP.Content allows you to promote posts from your forums to articles in the IP.Content Articles database.<br />\r\n<br />\r\nThe administrator can configure the specifics of this feature in the ACP under My Apps -> IP.Content -> Promote Article Settings. You can turn the system on and off, control which groups can copy and move posts to the articles section, and specify a few other details for the feature. A new hook is included with IP.Content which adds a button to each post labeled "Promote to Article". This button only shows up if you have permission to use the feature based on the ACP configuration.<br />\r\n<br />\r\nWhen clicked, the button will take you to a new form where you can formalize the details of the new article. You can tweak the text and title, upload an image, and specify other pertinent details. If you are able to both move and copy posts to the articles section, you will also be asked which type of promotion you wish to use. Upon submitting the form, IP.Content handles the rest.<br />\r\n<br />\r\nThis new feature can be used to showcase important content otherwise hidden in your forums by pushing this content to your frontpage. It is then up to you whether you want a copy made in the articles section (leaving the original post in tact), whether you want to actually move the post to the articles section, and whether you want any cross-linking left in place. With such powerful options, we are sure you will find many uses for this great tool available in IP.Content.\r\n \r\n </td>\r\n \n\r\n <td>\r\n \r\n Mar 15 2010 05:00 PM\r\n \r\n </td>\r\n \n\r\n <td>\r\n \r\n http://localhost/upl...7ae5b4e.png\r\n \r\n </td>\r\n \n\r\n </tr>\r\n \n </table>\r\n </div>\r\n </div>\r\n \r\n <br />\r\n <div class='topic_controls'>\r\n <!--hook.if.skin_global.paginationTemplate.haspages.pre.startif--><!--hook.if.skin_global.paginationTemplate.haspages.post.startif--><div class='pagination clearfix left '>\n <ul class='ipsList_inline back left'>\n <!--hook.if.skin_global.paginationTemplate.firstpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.firstpage.pre.else--><!--hook.if.skin_global.paginationTemplate.firstpage.post.else--><!--hook.if.skin_global.paginationTemplate.firstpage.post.endif-->\n <!--hook.if.skin_global.paginationTemplate.prevpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.prevpage.pre.else--><!--hook.if.skin_global.paginationTemplate.prevpage.post.else--><!--hook.if.skin_global.paginationTemplate.prevpage.post.endif-->\n </ul>\n <ul class='ipsList_inline left pages'>\n <li class='pagejump clickable pj0321775001'>\n <a href='#'>Page 1 of 9 <!--<img src='http://p125180.ipscdn.com/public/style_images/master/dropdown.png' alt='+' />--></a>\n <script type='text/javascript'>\n ipb.global.registerPageJump( '0321775001', { url: \"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1<!--hook.if.skin_global.paginationTemplate.furlinfo.pre.startif--><!--hook.if.skin_global.paginationTemplate.furlinfo.pre.else--><!--hook.if.skin_global.paginationTemplate.furlinfo.post.else--><!--hook.if.skin_global.paginationTemplate.furlinfo.post.endif-->\", stKey: 'st', perPage: 1, totalPages: 9, anchor: '' } );\n </script>\n </li>\n <!--hook.if.skin_global.paginationTemplate.normalpages.pre.startif--><!--hook.if.skin_global.paginationTemplate.normalpages.post.startif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.outer.pre--><!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.post.startif-->\n <li class='page active'>1</li>\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.endif--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.pre.else--><li class='page'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=1\" title=\"<!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.startif--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.else-->2<!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.else--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.endif-->\">2</a></li><!--hook.if.skin_global.paginationTemplate.activepage.post.else--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.inner.pre-->\n <!--hook.if.skin_global.paginationTemplate.activepage.pre.startif--><!--hook.if.skin_global.paginationTemplate.activepage.pre.else--><li class='page'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=2\" title=\"<!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.startif--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.pre.else-->3<!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.else--><!--hook.if.skin_global.paginationTemplate.hasRealTitle.post.endif-->\">3</a></li><!--hook.if.skin_global.paginationTemplate.activepage.post.else--><!--hook.if.skin_global.paginationTemplate.activepage.post.endif-->\n <!--hook.foreach.skin_global.paginationTemplate.pagination.inner.post-->\n<!--hook.foreach.skin_global.paginationTemplate.pagination.outer.post--> <!--hook.if.skin_global.paginationTemplate.normalpages.pre.endif--><!--hook.if.skin_global.paginationTemplate.normalpages.post.endif-->\n </ul>\n <ul class='ipsList_inline forward left'>\n <!--hook.if.skin_global.paginationTemplate.nextpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.nextpage.post.startif-->\n <li class='next'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=1\" title=\" - Next page\" rel='next'>Next</a></li>\n <!--hook.if.skin_global.paginationTemplate.nextpage.pre.endif--><!--hook.if.skin_global.paginationTemplate.nextpage.post.endif-->\n <!--hook.if.skin_global.paginationTemplate.lastpage.pre.startif--><!--hook.if.skin_global.paginationTemplate.lastpage.post.startif-->\n <li class='last'><a href=\"http://localhost/index.php?/page/articles.html?sort_col=record_updated&sort_order=desc&per_page=1&st=8\" title=\" - Go to last page\" rel='last'>»</a></li>\n <!--hook.if.skin_global.paginationTemplate.lastpage.pre.endif--><!--hook.if.skin_global.paginationTemplate.lastpage.post.endif-->\n </ul>\n </div><!--hook.if.skin_global.paginationTemplate.haspages.pre.endif--><!--hook.if.skin_global.paginationTemplate.haspages.post.endif-->\r\n </div>\r\n <br /><br />\r\n</if>',block_cache_last=1350712477 WHERE block_id=24
That is but one page, and one record on that page, of a plugin block I am making.... for no reason should such a block, with pagination, be cached in the first place, much less the gigantic insert/update on *top* of the dynamic data pulls that a plugin block often has to do.
Fact, because of this, the exact same code in a hook, with settings vs block configuration, will weigh a LOT less than the block, with no way to block this behavior in prod, even at a programmatic level within the block source.
The only reason one of efficiency mind would even USE a block right now over a hook is re-usability, that very thing that makes blocks truly unique, which is why I am using a plugin here, but this seriously pains me.
Edit: Also, *why* is this not run on shut-down in the first place? even a cached block would benefit from shutdown inserts vs immediate.
Edited by Marcher Technologies, 20 October 2012 - 01:43 AM.
#7
Posted 20 October 2012 - 04:21 AM
Why do you keep Cache data on MySQL is out of my head honestly. Instead of running queries to update cached data , you should directly allow Administrator to save templates as PHP files on actual server that can be cached by any PHP accelerator. It will be way more efficient.
- MisterPhilip likes this
Mert Gokceimam
CTO / Greenlinks Bv
#8
Posted 20 October 2012 - 04:29 AM
Why do you keep Cache data on MySQL is out of my head honestly. Instead of running queries to update cached data , you should directly allow Administrator to save templates as PHP files on actual server that can be cached by any PHP accelerator. It will be way more efficient.
http://community.inv...lock/?p=2290108
I argued the same... and actually made template logic pages do exactly that.
- Alfa1 likes this
#9
Posted 22 October 2012 - 09:47 AM
*please* give it another shot soon....... even a flag on the source of plugin blocks that says the block is not cacheable that would not run this would help insanely.
As I said (less than a month ago), it's something we're aware of. We made a small change to try to tackle this a while back and it caused many severe issues in various places (I'm sure you recall), so we undid that change for now. When we get to a major release point where we can rewrite how the area is handled, we will certainly take a look. We know about the issue. We will check on it, I promise. ![]()
- Alfa1 and Marcher Technologies like this
Developer / Senior Support
If it sounds like fun, it's not allowed on the bus!

Invision Power Services, Inc.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












