GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.35k stars 824 forks source link

Part of check_permissions extremely slow #1994

Closed Donkie closed 6 years ago

Donkie commented 6 years ago

Describe the bug Running most commands take next to forever (multiple minutes sometimes) for me on my Ubuntu 14.04 server with a HDD drive. I've analyzed the issue using iotop and found that a process with the command 'find "/my/server/files" -not -user steam' occupies a whole lot of I/O usage. This HDD drive is rather slow I've found, and I got quite some files in said folder, but that shouldn't affect the performance of just starting the server.

The culprit code is found at https://github.com/GameServerManagers/LinuxGSM/blob/0276b943e37293b68f3dbc2aca4e6f57fa39073b/lgsm/functions/check_permissions.sh#L21-L25 which, from my knowledge, tries to look through every single file in that folder and make sure the permissions are set correctly? Why is this necessary?

To Reproduce Steps to reproduce the behaviour:

  1. Have a slow drive
  2. Have many files in your server files directory
  3. Run any LGSM command

Expected behaviour That the command was fast and smooth

Minimum Information Game server: Garry's Mod https://hastebin.com/onufenuvox

Additional context

Donkie commented 6 years ago

After some additional research I found that this is partially my fault, an addon I had installed had created ~36,000 folders with logs which took some times to look through. However, I still don't think such a case should affect the performance of this program.

dgibbs64 commented 6 years ago

The permissions check normally takes less than a second to run. This is definitely the fault of the addon creating an extremely excessive number of files and dirs. So I would expect the find command to take a long time to get through all that.

So im not sure how you can think that having 36,000 dir's to scan shouldn't affect the performance of LinuxGSM.

What is the addon you are using? as there are checks for some gmod logs in LinuxGSM to clear them after x days

Donkie commented 6 years ago

I expected LGSM to not scan through my entire files at all every time I ran a command, why is this even necessary (especially with commands like stopping the server)? It should be up to the server software itself to check for permission issues if that's necessary in my opinion.

Even with all these directories removed it takes me atleast 5 seconds to perform the permission check.

It's a custom lua based anti cheat called Cake anti-cheat. It creates a directory for every player that joined the server with information about him. Sadly since they're not date based they can't be automatically cleaned.

UltimateByte commented 6 years ago

This check has ben created to prevent issues while starting/stopping/updating the server. Since LinuxGSM cannot know when the user will actually make mistakes with file ownership and permission, it has to run the command every single time. While I can agree checking every time is agressive, I see no workaround, I don't want to leave the user disable the check since there would be dangerous behaviors, and ultimately, I've never seen a scenario where the delay for the check is noticeable.

dgibbs64 commented 6 years ago

It should be up to the server software itself to check for permission issues if that's necessary in my opinion.

Out of the 80+ servers, 0 do permissions checks. It's the users responsibility to check permissions normally. However, we removed that burden and added the feature for LinuxGSM to do the check instead of the user, there is no faster way to do that than using the find command. The feature has been in place for a very long time now and this is the first time an issue has been raised regarding a slowdown, so your situation is an exception to the norm.

The check is in place as many users don't understand permissions and can sometimes mess them up causing odd behaviour that's hard to diagnose. As @UltimateByte states the check is aggressive but there is no other way to guarantee that there are no permissions issues every time. Hope this explains why it has to be done.

Donkie commented 6 years ago

I understand.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.