Closed (won't fix)
Project:
Drupal core
Version:
6.x-dev
Component:
user system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
25 Jan 2007 at 16:57 UTC
Updated:
3 Jun 2008 at 21:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
hickory commentedA large proportion of the database calls for building pages were during user_load, so I made a patch based on node_load.
The main difference is that this doesn't use the is_object() checks that node_load uses, as they don't seem to be necessary - are these for compatibility with older versions of PHP?
Comment #2
hickory commentedPatch is against the DRUPAL-5 branch.
Comment #3
moshe weitzman commentedseems like a good idea. eventually, this should be against HEAD in order to cvs commit team to review.
Comment #4
RobRoy commentedNew feature, so marking 6.x-dev.
Comment #5
hickory commentedI've been using this for a little while now, and it can cause problems if modules modify the user object outside of hook_user, so if this is commited module owners will have to be aware of the change. I do still think it's worthwhile though.
Comment #6
moshe weitzman commentedThe new menu system [see _menu_translate()] is calling user_load(1) 9 times on a view profile page. same for edit profile. we should either cache user load or make menu smarter. load can be expensive since we do hook_user(load) every time.
Comment #7
chx commentedEasy...
Comment #8
killes@www.drop.org commentedInstalled patch, created story, edit my account and profile, still works.
Comment #9
pwolanin commentedI'm not sure this is a good idea, since the menu system doesn't know the details of the objects being loaded - especially in combination with a load function that may be looking at additional parts of the path.
I'd suggest solving the user load on profile pages problem specifically - I already have considered (but not yet implemented) it as part of this patch: http://drupal.org/node/111481 since it requires a separate load function in any case.
Of course, that patch is still waiting on: http://drupal.org/node/177488
I was away for the weekend, I'll try to get back to that one tonight.
Comment #10
chx commentedthat never should happen, as the load functions can be called from any page if there is a menu item pointing at them that's why we have that linked issue. I think we could agree on that a load function should be a simple black box: in comes the object id, out comes the object.Comment #11
chx commentedhuh?
Comment #12
chx commentedLet's try again, I suspect i garbled the html.
that never should happen, as the load functions can be called from any page if there is a menu item pointing at them that's why we have that linked issue.
Comment #13
pwolanin commented@chx - well, it seems that the various forms of the patch here: http://drupal.org/node/177488
allow a load function to use more than just the single object ID to determine what to load. That's why I liked the form of the patch that passed in directly the map and index - it makes this possibility more clear/explicit. I think this is a useful tool - think, for example, about node revisions - node load wants you to pass in both the nid and the vid. So, putting in this patch would potentially block the functionality being introduced by http://drupal.org/node/177488.
Comment #14
chx commentedThis solves a problem here and now. We can easily add caching to 177488 too. But that issue does not belong here.
Comment #15
panchoI'm very much in favor of this!
Still I'm not sure this change could make it into D6, though it would improve performance.
Would be great, if someone like chx or pwolanin could follow up...
Didn't apply anymore, after #184022 went in. For now, I rerolled this, but only caching functions with non-array arguments though. Wasn't sure if and how we'd cache the other ones. With this incomplete caching, about 10ms are saved on my machine for profile pages.
Comment #16
pwolanin commentedcode looks reasonable
Comment #17
pwolanin commentedother than non-unix line endings, patch applies cleanly. I don't see any problems testing with a user profile, etc.
Comment #18
pwolanin commented@Pancho - thanks for taking this up again.
However, after debating with chx, the only major performance gain (for core at least) will be on user profile pages, as far as I know. So, lets just make it clear that responsibility for caching to the load function somewhere in the docs?
While it seems unlikely that the cached data would get stale, one can imagine some scenarios where the page callback alters the object and hence affects which tabs/links should be rendered.
Comment #19
vanvemdenI just checked the api for the user_load() function in D6 and noticed that user_load() still not caches users. Any reason in particular why it was decided not to do this?
Comment #20
moshe weitzman commenteduser_load caching is the most needed spot. see #91786: user_load() static caching for new patch.