Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
menu system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
21 Oct 2005 at 09:47 UTC
Updated:
7 Feb 2007 at 18:16 UTC
Jump to comment: Most recent file
When I enable all modules in core, the menu array eats over 800K of RAM. This indicates that we are bound to have serious problems when lots of nodes are added to the menu tree via menu OTF. We need to have an SQL table against which we can load only those that are visible. I think with proper indexing we could even have some performance win.
| Comment | File | Size | Author |
|---|---|---|---|
| #57 | newmenu_23.patch | 214.51 KB | chx |
| #55 | newmenu_22.patch | 214.5 KB | chx |
| #54 | newmenu_21.patch | 212.86 KB | ChrisKennedy |
| #53 | newmenu_20.patch | 212.43 KB | chx |
| #52 | newmenu_19.patch | 209.5 KB | chx |
Comments
Comment #1
chx commentedRoadmap of the new menu system:
This will let us focus on the task at any time. The point of this post is to stress if you apply the patch to be submitted then your Drupal will not have anything listed in 2,3,4: navigation block, primary links, tabs, breadcrumbs, editable menu and you must start with a fresh database and be ready to loose it ongoing.
Of course, I have at least the ideas (well, some code too) to get all four so Drupal 6 won't be crippled for long.
Comment #2
moshe weitzman commentedNice roadmap. Looking forward to this.
Comment #3
Paul Natsuo Kishimoto commentedSubscribing.
Could you post some of the code, even if not in the form of a patch? I'm curious as to how this will work.
Comment #4
chx commentedPreliminary code is in my sandbox for two months now (menu_create.php , newmenu.patch and test.php).
Patch is coming this weekend: I have most modules converted and menu.inc working. I just want to finish converting and do some basic testing & benchmarking.
Comment #5
chx commentedDocumentation is at http://drupal.org/node/102338 .
Comment #6
chx commentedComment #7
chx commentedhook_start was not called.
Comment #8
chx commentedA copy-paste error caused map_arguments to be filled with access arguments...
Comment #9
chx commentedI needed to make an exception to the inheritance rules so that node/add/story does not inherit from node/%/% (defined in comment), the rule is that if you have two percent signs then on build time this ancestor is not taken into consideration for inheritance purposes. I hope I will get people to review and discuss such decisions.
If you want to benchmark this then remove the menu_rebuild() command from index.php. I kept it there because it's so useful when hacking menu.
Comment #10
chx commentedI discussed the above problem with Steven and now we inherit by path and not ancestor. This was used in the skelton version but I thought ancestors woudl be better. I was wrong. (When custom menu items will come, they will be treated as if run time)
Comment #11
chx commentedwe have hook_boot and hook_init as discussed on #drupal . This means that if you used hook_init, now you need to upgrade because bootstrap.inc calls hook_boot.
menu_map now assists in arriving to a drupal_not_found .
Comment #12
dries commentedIt's still difficult to grok the semantic difference between _boot() and _init(). Not sure it can be made clearer but I can see this being a source of confusion.
I'd write 'value 1' and 'value 0'. When you say 'bit 1', it makes me think of the bit at position 1.
In the example, what happens with 'foo'? The original path consists out of 4 parts, but the pattern only has 3. This needs to be clarified in the code comments. No need to clarify it in the issue.
There are some typos in the following snippet (i.e. 'will is an integer). Also, it is not quite clear what you're trying to say. The documentation describes the implementation details but not the bigger picture? I.e. why do we want to unserialize an array in an awkward way? Needs to be documented in the code. :-)
Comment #13
chx commentedI renamed the hook invokes but not the implementations. Fixed.
Comment #14
m3avrck commentedSubscribing...
Comment #15
chx commentedRerolled and adjusted the comments per Dries' advice.
Comment #16
BioALIEN commentedSubscribing (I think its time we have a subscribe feature in D6)
Comment #17
scroogie commentedsubscribing
Comment #18
dfletcher commentedThis breaks the system_get_module_admin_tasks function which still expects the old ['path index'] key from menu_get_menu. It will need to be rewritten. The effect is that the page q=admin/by-module has no module specific links.
Comment #19
dfletcher commentedAnother problem in system.module, system_main_admin_page seems to return halfway through, causing q=admin to white-screen.
Perhaps this is intentional and both the admin and admin/by-module above are waiting for the core of the menu system to stabalize - I'm unsure.
Comment #20
chx commenteddflechter on IRC added after finding the admin pages not working:
The admin pages are navigational aids -- phase 2. I added return; // TODO: this needs to be rewritten for the new menu system. to the beginning of affected functions in system.module. They are now empty as they should be but do not emit error messages. In the previous patches I started converting one of these functions but no, this is clearly phase 2.
Comment #21
dfletcher commentedI really need to provide more context in IRC.
I was talking about my little test module which was thoroughly tested. That is the part I found to be solid, obviously not the admin stuff ;)
Comment #22
chx commentedThe earlier patch contained an experiment from another patch. And more improvements.
Comment #23
chx commentedIf I would be particularly bold I would mark this RTBC because dfletcher, dvessel, bdragon, chrisxj have visited every single defined path (more than 200) and quite some that are not specifically defined. Thanks guys. I just needed to do 20 or so instead of 260+ and fix the occassional error. All this is documented http://groups.drupal.org/node/2354 . Unlike in the earlier patches, the menu_get_active_help now works, its conversion was so trivial.
Comment #24
Tobias Maier commentedyou included your settings.php
Comment #25
chx commentedSigh. This happens when our bzr mirror breaks.
Comment #26
chx commentedNew day, new patch-- HEAD broke search and node.
Comment #27
chx commentedThat was still yesterday's patch :(
Comment #28
ChrisKennedy commentednode/add/page and node/add/story both return "page not found" errors for me.
Comment #29
chx commentedI see them on 4si.hostignition.com/d, the public demo and developer site of this patch. Register a user, because anonymous has no rights but authenticated users have every right.
I typed 4si.hostignition.com/d/node/add/story and I see 'Submit story'. Want a screenshot?
Comment #30
ChrisKennedy commentedHmm, I logged out and logged back in and it worked. Maybe it was a caching issue.
I did notice that if you go to /user when logged out it doesn't display the login form, but instead tries to display a user profile ("member for 37 years 3 weeks").
Comment #31
chx commentedNow if you visit 'user' as anonymous you get access denied -- as I intended. The login page is user/login.
Comment #32
chx commentedI keep closely with HEAD because I hope that very soon after branching this gets in and branching is soon...
Comment #33
chx commentedRemoved debug code (the menu_rebuild in index.php makes debugging easier).
Comment #34
chx commentedI have removed the install.php patch as well, that was not intended...
Comment #35
heine commentedwatchdog_help was lost due to collateral damage.
Comment #36
heine commentedA basic benchmark. prepatch has all blocks disabled.
Comment #37
dries commentedHeine, how do I need to read/interprete these results? What format are they in?
Comment #38
moshe weitzman commentedI gave this patch a decent workout tonight. My first impression is bliss - these are the fastest pages i've ever served on my dev box. It is magical to see a single simple query retrieve the active callback. For node/1, that query is
SELECT * FROM menu WHERE path IN ('node/1','node/%','node') ORDER BY fit DESC LIMIT 0, 1the menu cache is gone. hook_menu_alter() is introduced. there is a lot to love here.
code-wise, looks good. i think modules will easily convert to this scheme. there is some binary magic which i don't understand but chx and dries do, so thats all good.
there is some debugging in the patch, and some pages which await rewrite. i think thats OK, but i'll wait and see where chx intends to leave off for this phase 1. from my perspective, this is close to rtbc.
Comment #39
Paul Natsuo Kishimoto commentedI think maybe Heine meant:
and
... where 'pre' is 'pre-patch', 'post' is 'post-patch', and the first dataset is with only the default enabled core modules.
Please correct me if I'm wrong! I calculated percentages to compare—if it's really at least 20% decrease in page time / request rate, that's very snappy.
Comment #40
chx commentedMoshe, thanks. The pages that await rewrite are navigational aids, hence phase 2, they do not belong to this patch.
The known_keys debugging in menu.inc is something to be only removed before RC, I think. It's of great help when converting a module. Of course, that's only my opinion.
Comment #41
chx commentedAnd Paul's interpretation is quite right.
Comment #42
BioALIEN commentedWow, impressive benchmark results :)
Comment #43
Jaza commentedI haven't tested this patch yet, but I've read the whole thing, and it looks really seriously amazing. You're a genius, chx! (but hey, we already knew that).
My biggest concern is that there doesn't seem to be proper support for non-integer wildcards in menu paths. E.g. in the patched version of
node_menu(), there should just be one path for all the custom node type editing pages:admin/content/types/%. But instead, there's a foreach loop that's defining a path for each node type. This is not good: we need to be able to use strings as wildcards as well! I'm sure there will be plenty of other places, in core and contrib, where strings will need to be used as wildcards.The binary tricks in
menu_get_ancestors()are all voodoo to me, but if they work as advertised, then I say bring it on!!Comment #44
kbahey commentedGood work chx.
Subscribing.
Comment #45
chx commentedThere is nothing in there that would force % to be numeric. It can be whatever you want. However, in *most* cases it is a database ID and then you call map callback upon it and the default (but only the default!) map callback indeed checks for is_numeric. But noone forces you to define a map callback or even if you do, feel free to use your own.
Some suggested earlier using %d and %s but this could lead to huge database queries, with 728 maximal possibilites in the menu query instead of the 63 we currently have.
Comment #46
chx commentedBTW. the admin/content/types/% I actually inherited from the old menu system and it is certainly possible to simplify -- later. We enough changes already, I believe.
Comment #47
chx commentedThe maths is not voodoo by far (just wait until the hook registry/ordering patch hits with DFS of graph theory inside). http://en.wikipedia.org/wiki/Bitwise_operation will explain. It's rather trivial, IMO.
Comment #48
Jaza commentedOK, I have spoken to chx on IRC, and in case anyone else reads the patch and worries like I did, please rest assured:
The
is_int()check inmenu_unserialize()has nothing to do with wildcards. It is perfectly possible to have non-integer wildcards with this patch.BTW, I did actually read http://en.wikipedia.org/wiki/Bitwise_operation while I was looking at the patch, and it helped a lot. The operators themselves are not voodoo, it's just applying them in code that seems like voodoo to a lot of people (including myself).
Comment #49
chx commentedI think I should give credit before I get all. The patch was inspired by a mail from JonBob, I got great ideas in Brussels from Merlin, Adrian, Moshe and Dries (I hope I have not left out any of you guys), and later Steven helped straight out ancestors/parents. Only the binary maths and map callback are my ideas. dfletcher, dvessel, bdragon, chrisxj and Heine took great pains to test it througly.
Comment #50
Caleb G2 commentedsubscribing
Comment #51
chx commentedAs per Dries' request so that Drupal remains usable after this is commited: we now have the navigation block. I am extremely unwilling to bring more into this patch.
Comment #52
chx commentedI upped system.install with the many new fields and also this version has an index on fit which will give you a minor boost, especially on long paths.
Comment #53
chx commentedHeh! I forgot out access checking (thanks ChrisKennedy and Heine).
Comment #54
ChrisKennedy commentedFixed a few minor coding style errors, added a few basic doxygen comments, changed home to Home in the breadcrumb placeholder.
The issue with "create content" (a MENU_GROUP_ITEM) showing when no items are available can be tackled post stage 3.
From #drupal:
Comment #55
chx commentedmenu.inc uses int2vancode which resided in comment.module. No more.
Comment #56
moshe weitzman commentedverified that the most recent patch works as advertised. RTBC. later phases will happen later.
Comment #57
chx commentedReroll.
Comment #58
chx commentedDries committed it.
Comment #59
(not verified) commented