MU Advanced: Issues and Discussion
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • September 03, 2010, 12:24:22 PM
Home Forums Contact Tags FAQ Links News Login Register
* *
Navigation Menu
Search

Random Quotes
Hope, It is the quintessential Human delusion, Simultaneously the source for your greatest strength and your greatest weakness!
- The Architect
Pages: [1]   Go Down
  Print  
Author Topic: "preload" and option cache for options that are not set...  (Read 690 times)
0 Members and 1 Guest are viewing this topic.
ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« on: June 10, 2008, 12:05:05 PM »

So, I've been looking into why my pages seem to generate so many queries, and I think I've come across an interesting case.

It appears as if several of my queries are for individual blog options that are not set. So for example, if I have a plugin that implements some custom theme option, but the user has never set that option, then many of the plugins will check to see if the option is set, and if it's not set, then just do the default behavior. Works fine, sounds reasonable.

But, if that option is never set, then it also is never auto-loaded, which means it will not be in the cache on the first go around. Which means a bunch of extra single queries that would have been saved by auto-load had the option been previously set.

Here's my questions:

1) Has anyone ever noticed this before?
2) Has this ever been discussed by the mu core team as an issue?
3) Any thoughts on how to handle optimizing this? [killing all the plugins is not a reasonable answer... although I know you all want to suggest it. Wink ]

Logged

Yep, that's me... riding my bike 204 miles in one day.
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #1 on: June 10, 2008, 01:40:41 PM »

What are you using for object cache?  The reason why I ask is that we and others have noticed that the file based object cache plugins appear to not work correctly on mu and we've removed them for teh time being.  We're betting that they face the same issues as the built in object cache did a few months ago.  I just haven't had that much of a chance to look at the issue right now.

And I've got to admit that debugging something like that may be a bit too much for my limited skills.
Logged

ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« Reply #2 on: June 10, 2008, 04:11:44 PM »

What are you using for object cache?

Actually, I was seeing this behavior in the stock 1.3-1.5.1 code bases. I've been testing/debugging several different versions in order to determine if it was version specific.

And what I've found is not really a bug so much as a "feature blind spot"... which is to say that the wp_load_alloptions() function does a great job of loading all options that have a set value, but doesn't do anything to handle options that have not yet been set.

Once these things have been accessed once, they are cached... but imagine that in the course of generating a page you call get_option() on 20 different options that were not previously set, the result are 20 additional sql queries that essentially do nothing other than to inform the system to behavior in a default manner.

Once get_option(optionname) is called once, then you can call it 100 more time without generating another SQL query (since the cache is working)... but you did have to pay the price of the initial request...
Logged

Yep, that's me... riding my bike 204 miles in one day.
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #3 on: June 10, 2008, 05:51:18 PM »

1.5.1 no longer has the object cache and I believe it was 1.3 that had the broken one.  That's why i was wondering how you were doing this.
Logged

ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« Reply #4 on: June 10, 2008, 08:25:36 PM »

1.5.1 no longer has the object cache

This is not consistent with the 1.5.1 code I have. The standard 1.5.1 code does appear to have an object cache found in wp-includes/cache.php. That object cache is an in memory only cache, and so it only shares cache objects within a single php thread.

It does indeed appear that 1.5.1 does not have a file based cache that caches objects between threads/processes and multiple page generation calls.

That being said, I can imagine that utilizing a better cache plugin could solve this problem ON THE SECOND PAGE HIT by persisting the fact that these options were not set between page calls and therefore saving the original DB query (on the second page hit).

What is the best wpmu based cache alternative out there?
Logged

Yep, that's me... riding my bike 204 miles in one day.
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #5 on: June 10, 2008, 09:15:39 PM »

I'll throw a vote for xCache.


Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #6 on: June 11, 2008, 07:45:32 AM »

Andrew and I passed this one around for a bit as it depends on your setup.  I know him and James had some "issues" witrh setting up, I believe, memcache for the main sites that they host and passed over it for their client sites. (At least that's how I remember the discussion we had.  I may be wrong.)

I remember Matt stating something about working in wp-cache into 2.6 although I'm not sure where that stands.  I noted that some 2.6 code got pushed out on trac but I haven't given it more than a causal glance yesterday. (T and TH are my big volunteers and medical days.  I get like 2 hours of coputer time if that.)

Logged

Tags:

Pages: [1]   Go Up
  Print  
 
Jump to:  


Login
 
 
Recent Posts
Recent Topics
No new topics.
Hot Tags
Whos Online
10 Guests, 0 Users
Home Forums Contact Tags FAQ Links News Login Register