I'm curious about your unit frames addon, and is the code optimization solely responsible for the 100x improvement? Or agUF is doing more stuff (aggro, range check, etc)?
I have to get a little wordy here, sorry. :)
I think there's only one feature missing from ag_unitframes, namely updates on targettarget and focustarget. Unfortunately, WoW doesn't generate events for these units, so AddOns would need to update them in OnUpdate code. As the MT I don't really care about targettarget health/mana being updated, I mainly use the targettarget frame so I can look at my pretty face in the portrait. ;) So that's the only difference I'm aware of: targettarget and focustarget only update if they change, while agUF updates these twice a second.
ag_unitframes has quite a few more features than my mod, all of which I have disabled. I never use this Banzai stuff, or range checking, or debuff coloring/sorting etc, or cast bars. My mod also doesn't have a GUI to set options, I use a hard coded table at the moment. I believe agUF uses DogTag for labels, I don't have that either. But all these features shouldn't affect the performance (in theory), since I disabled them in agUF.
One of the things that has an impact on performance is the event code. My event code looks like this:
function(frame, event, unitid) local callback = eventreg[unitid] if callback then callback() end end
which is used for all the UNIT_* events like UNIT_HEALTH. This approach is similar to PerfectRaid.
agUF uses Ace2 for events, and pretty much every unitframe registers for all event. So in a raid situation about 30 OnEvent handlers are called every time an event like UNIT_HEALTH fires, and every handler performs a check like [font=Verdana]if unit~=self.unit then return end[/font].
Another big difference: I think the only place where I use tables is for auras. The buttons, textures, counts etc that display buffs/debuffs are stored in arrays. But that's it for tables. I don't use globals, I don't use self:foo(...) or even manabar:SetValue(...), but I store everything (including function references) in upvalues. The latter would become manabar_SetValue(manabar,...) in my code. A little hackish (because it relies on the fact that manabar.SetValue is constant), but faster.
agUF on the other hand uses an OO-approach entirely based on tables, like the examples in PIL. From a performance point of view, the big disadvantage of that approach is that there is only one function closure per class, not per object. So all object data has to go into a table, you can't use upvalues. Whenever you need access to object data, you have to do a table lookup, which is slower than upvalue access. I'm not sure how much slower exactly, but upvalue lookup is O(1), and table lookups are probably in O(log n), maybe even O(n).