reticulatedpines / magiclantern_simplified

A Git based version of Magic Lantern, for those unwilling or unable to work using Mercurial. The vast majority of branches have been removed, with those thought to be important brought in individually and merged.
GNU General Public License v2.0
149 stars 51 forks source link

Consider removing large, statically allocated module_list #131

Open reticulatedpines opened 8 months ago

reticulatedpines commented 8 months ago

In module.c we have:

static module_entry_t module_list[MODULE_COUNT_MAX];

MODULE_COUNT_MAX is 64, and a module_entry_t has several char arrays for various module name fields. Total size is 0x2d00, 11kB (see output from: nm --print-size --size-sort --line-numbers magiclantern).

That's a significant cost on the lower memory cams. It would seem more logical if we kept the module info inside each module, and module_list becomes an array of module_entry_t *. We would then avoid paying this large fixed cost when loading ML, instead only paying 1/64th of the cost, per each module, when loaded.

reticulatedpines commented 8 months ago

Likewise for module_menu, size 0c1600, 5.6kB, due to 64 entries:

1927 static struct menu_entry module_menu[] = {
1928     MODULE_ENTRY(0)

It's less obvious how this gets populated, there's a bunch of horrible macro magic. Still, conceptually, having an array of pointers into modules to get their menus, makes more sense.

It doesn't use MODULE_COUNT_MAX to size this though, just hard-codes 64. So that wants fixing too.