• Print

Author Topic: The ULib hook library  (Read 14 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
The ULib hook library
« on: February 21, 2010, 11:07:59 pm »
The other day Python1320 (not sure if he's on the forums, just have him on MSN) was complaining that the ULib hook library, specifically how it handled priorities, was too slow. Instead of looping through just one table, ULib had every hook call looping through 41 tables. While the actual execution time this added was still hardly anything, I had to agree that things could be handled better with some tweaking.

So, after some thought about how this could be improved, I realized that I could keep the ULib priority system and make the hook system faster than garry's implementation. So, I did just that in ULib rev 108.  ;D
« Last Edit: February 22, 2010, 08:34:25 am by Megiddo »
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: The ULib hook library
« Reply #1 on: February 22, 2010, 07:48:34 am »
Very Nice!  ;D

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: The ULib hook library
« Reply #2 on: February 22, 2010, 11:26:36 am »
I was wondering about just how much faster I made it, so I started poking around the lua source code to see how the function garry was using is implemented. I think what he was using is implemented in n log n time, which would mean that the new iteration implementation is ~10x faster.

Of course, that number if off the record and unofficial. I think it's the case here, but it only applies to how quickly the hooks can be iterated over, not how quickly the hooks themselves are called. Still strange that garry didn't do it this way to begin with though.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: The ULib hook library
« Reply #3 on: February 22, 2010, 03:49:41 pm »
"Better, stronger, faster"
ULib - The Six billion dollar Gmod Library.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print