There is a lot of usefull calls of user_load() in _me_load_arguments() function.
So I have added internal caching (using static variables) to decrease number of this calls.
More accurate using of user_load() let's sites which has more users be faster.
Patch also adds one more argument - $reset which is FALSE by default and when is TRUE - will reset internal cache.

Comments

vladsavitsky’s picture

Status: Fixed » Needs review
StatusFileSize
new1.56 KB

Ok. Let me explain what patch is doing.

Me module on some user related pages do a lot of calls of user_load() function.
And this calls are equal. This means that on a high loaded sites with a lot of users a lot of useless SQL-queries of the same data about user will be done. This increases server loads and some visitors couldn't access site.

To see all this calls you can install devel module and at devel settings page check this:
* Collect query info
* Display query log
Than visit some pages and check user_load() call number at the bottom of page.

So this patch resolves this problem adding caching of users data and do not call user_load() each time if user's data already stored in cache.

For example, on our server I have this results:
Page - user_load() calls before/after
* / - 8/1
* /user - 24/1
* /user/me/edit - 23/1
* /user/me/edit/profile - 23/0
* /admin/user/user/list - 7/0
* /admin/content/comment/approval - 7/0
* /users/XXX - 10/4

So this patch should increase module perfomance.
Patch is attached to this comment.

nohup’s picture

Status: Needs review » Fixed

thanks, committed.

nohup’s picture

Status: Needs review » Closed (fixed)