Rebuilding the menu takes a long time when there are lots of projects

Migrated issue

Reported by: psynaptic

Rebuilding the menu takes a great deal of time when there are a lot of projects. This could be because lots of menu items are registered but I have yet to prove that theory. If this is proved to be correct, we could try using menu arguments instead of registering them in the menu system.

Here's an snippet of an strace of the process while clearing cache:

➜  api git:(7.x-1.x) ✗ strace -p 30038
Process 30038 attached - interrupt to quit
gettimeofday({1392767815, 315822}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\204\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 136) = 136
read(3, "\1\0\0\1\31?\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 1712
gettimeofday({1392767815, 444099}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\210\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 140) = 140
read(3, "\1\0\0\1\31?\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 1720
gettimeofday({1392767815, 570990}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\204\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 136) = 136
read(3, "\1\0\0\1\31?\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 1711
gettimeofday({1392767815, 572497}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\275\0\0\0\3SELECT menu_links.depth AS "..., 193) = 193
read(3, "\1\0\0\1\0017\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 88
gettimeofday({1392767815, 694870}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\204\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 136) = 136
read(3, "\1\0\0\1\31?\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 1714
gettimeofday({1392767815, 815221}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\206\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 138) = 138
read(3, "\1\0\0\1\31?\0\0\2\3def\3dev\nmenu_links\nmen"..., 16384) = 1718
gettimeofday({1392767815, 949190}, NULL) = 0
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(3, "\207\0\0\0\3SELECT menu_links.*\nFROM \nm"..., 139) = 139