Pac is full of a lot of crap that burns CPU by doing completely unnecessary or redundant work, as is the case here.
The event part's OnThink() method calls expensive spaghetti bandaid function fix_args() every single tick.
|
function PART:OnThink() |
|
self.nextactivationrefresh = self.nextactivationrefresh or CurTime() |
|
if not self.singleactivatestate and self.nextactivationrefresh < CurTime() then |
|
self.singleactivatestate = true |
|
end |
|
|
|
local ent = get_owner(self) |
|
if not ent:IsValid() then return end |
|
|
|
local data = PART.Events[self.Event] |
|
|
|
if not data then return end |
|
|
|
self:fix_args() |
|
self:TriggerEvent(should_trigger(self, ent, data)) |
|
|
|
if pace and pace.IsActive() and self.Name == "" then |
|
if self.pace_properties and self.pace_properties["Name"] and self.pace_properties["Name"]:IsValid() then |
|
self.pace_properties["Name"]:SetText(self:GetNiceName()) |
|
end |
|
end |
|
|
|
end |
I do not see any reason why fix_args must do its bad inefficient work every single tick. It is already used once in SetEvent(), where it at least makes sense as a sanitizer. But, if the event arguments can somehow be modified outside of a SetEvent(), then 1) fix that horrible footgun, and 2) change fix_args() or its call inside OnThink() to not be so horrible.
For example, with a basic invalidation check like this...
function PART:fix_args()
if (self.Arguments == self.LastFixedArguments) then return end
-- expensive code
self.LastFixedArguments = self.Arguments
end
...I get a ~15% reduction in outfit rendering time on my pacs that have about ~50 event parts each. No breakages. That's rare.
The event and proxy parts are notoriously costly and widespread, so unless I am missing something here, I see no reason why this cannot be fixed.
Pac is full of a lot of crap that burns CPU by doing completely unnecessary or redundant work, as is the case here.
The
eventpart'sOnThink()method calls expensive spaghetti bandaid functionfix_args()every single tick.pac3/lua/pac3/core/client/parts/event.lua
Lines 3698 to 3720 in e40dfa5
I do not see any reason why
fix_argsmust do its bad inefficient work every single tick. It is already used once inSetEvent(), where it at least makes sense as a sanitizer. But, if the event arguments can somehow be modified outside of aSetEvent(), then 1) fix that horrible footgun, and 2) changefix_args()or its call insideOnThink()to not be so horrible.For example, with a basic invalidation check like this...
...I get a ~15% reduction in outfit rendering time on my pacs that have about ~50 event parts each. No breakages. That's rare.
The event and proxy parts are notoriously costly and widespread, so unless I am missing something here, I see no reason why this cannot be fixed.