Chessnut / NutScript

A free role-play framework for Garry's Mod.
http://nutscript.rocks
MIT License
94 stars 77 forks source link

Different schema name creates FPS lag #562

Closed blt950 closed 7 years ago

blt950 commented 9 years ago

This is a extremely odd issue, but I've tested and recreated it on three different computers. The issue has no connection with the schema it self for Nutscript, but the schema name is the issue. Even if you create a blank schema with sh_schema.lua and the basic info, this still occurs.

If you change the schema name from HL2RP to something else, you'll notice when you walk around in the map small FPS drops each second, which is quite noticeable. You can see it in net_graph

Two ways to reproduce:

  1. Make a blank new skeleton schema with any other name than "hl2rp". You will experience this. Once you change back to "hl2rp", it's gone.
  2. Download newest HL2RP schema and rename the folder and .txt file to something else. You will experience this. Once you change back, the FPS lag is away.

I noticed this when my own custom schema is named "bmrp" this occured. I believe this started maybe after a Nutscript update a quite while ago, because I can't recall to have experienced this in the very beggining of my development of the schema.

Thadah commented 9 years ago

Can't replicate using 2nd way, my FPS are the same, and net_graph 5 doesn't show anything abnormal

blt950 commented 9 years ago

Really odd. Did you get the lag with the 1st way, or you didn't try it?

Hmm, is there any caches or something I should maybe refresh to try fix this? Since it's FPS I suppose it's usally a clientside bug? Odd I got it on all 3 computers though and that a gamemode folder name can trigger it.

Chessnut commented 9 years ago

I can't replicate either methods.

Chessnut commented 9 years ago

Is your issue like the one in #559

Thadah commented 9 years ago

Could be an issue regarding client Garry's Mod addons that somehow break the gamemode? It's a really weird issue any way you see it though.

blt950 commented 9 years ago

Hm yeah, I'll try today to debug the client Gmod and see if I find anything interesting.

@Chessnut Indeed, it looks pretty much as the same issue as you referenced.

blt950 commented 9 years ago

Alright I've tested this out for some hours and I've found the issue.

The issue is clientside and is located in my and supposedly other content packs of playermodels. Once I used any Black Mesa Source playermodel the game started to lag as mentioned earlier. The source of the lag is actually from Nutscript, the "legs" plugin. Once I removed this plugin and used the playermodel again, the lag was gone. So Chessnut, is there anything in the legs plugin you did a while ago that might have started this?

@Chessnut I don't know if it's normal, but the HUD bars (health and stamina) once they're drawn, I actually loose 100 FPS (200fps to 100fps). Just saying if it's anything to think about.

Chessnut commented 9 years ago

The bones might be related to the legs issue.

DefenderVex commented 9 years ago

I noticed I had this similar issue in #559. I did manage to track it down to being clientside, Like @blt950 I think as well it's something to do with models. My current belief is that it's caused when a model didn't register on the serer properly. IE, it didn't mount.

blt950 commented 9 years ago

Yeah, it seems like a mix of maybe both models and Nutscript. I suppose this happens to more than only BMS models, so it's worth to try get fixed somehow :)

I've now broke down the whole leg plugin to find the code which is causing this lag:

Line 121-130

local newMaterials = client:GetMaterials()
    local materials = self.legs:GetMaterials()

    for k, v in ipairs(materials) do
        if (v != newMaterials[k]) then
            return true
        end
    end

If you comment out the FOR loop, it still lags. It seems it's something with the two locals that causes this lag. @Chessnut anything you can optimize or do here to maybe fix it? Would be greatly appreciated :)

Edit: I fixed it by changing the nutLegCheck timer to 10 seconds, since it was 0.5 seconds, which explains the lag each second as well. I suppose :GetMaterial() method is maybe a bit heavy method to run that often? I don't know if my fix is the most convenient one, but you can decide :)

Chessnut commented 9 years ago

Setting two local variables isn't going to cause lag. On Thu, Jul 23, 2015 at 02:16 Blt950 notifications@github.com wrote:

Yeah, it seems like a mix of maybe both models and Nutscript. I suppose this happens to more than only BMS models, so it's worth to try get fixed somehow :)

I've now broke down the whole leg plugin to find the code which is causing this lag:

Line 121-130

local newMaterials = client:GetMaterials() local materials = self.legs:GetMaterials()

for k, v in ipairs(materials) do
    if (v != newMaterials[k]) then
        return true
    end
end

If you comment out the FOR loop, it still lags. It seems it's something with the two locals that causes this lag. @Chessnut https://github.com/Chessnut anything you can optimize or do here to maybe fix it? Would be greatly appreciated :)

— Reply to this email directly or view it on GitHub https://github.com/Chessnut/NutScript/issues/562#issuecomment-124030281.

Chessnut commented 9 years ago

The problem is probably something is making the legs invalid (you don't have the model?) which causes legs to be re-created every 0.5 seconds.

blt950 commented 9 years ago

Well no, the variables itself doesn't cause the lag, though that they're called each 0.5 second is a bit much? Well I notice the FPS in net_graph when I changed the interval to 10 seconds, but when playing you don't notice the drop.

Either way, I've the exact same model pack on both server and client side, no errors, not missing anything. I don't think it's the part which creates the legs is the source of the lag, because that only happens if the legs are not valid, in this case they're valid, because the lag completely disappears if I remove the code in line 121-130, meaning that part of the code is getting called.

Chessnut commented 9 years ago

Can you send me one of the models so I can test this?

blt950 commented 9 years ago

Sent on steam, but here is a copy just in case.

https://www.sendspace.com/file/866jfh All copyright and legal stuff like that belongs to the Black Mesa Source team of course.

Check out the bug with nutModelPanel as well once you test it out, with the rotation/animation in character creation, that's really weird as well.