Skip to content

Bulk SDKHooks perform significantly worse on Linux than Windows #1935

@Vauff

Description

@Vauff

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version:
    Affected: Debian GNU/Linux 11 (bullseye)
    Test comparison: Microsoft Windows Server 2019 Standard
  • Game/AppID (with version if applicable): CS:GO 730/740
  • Current SourceMod version: 1.11.0.6931
  • Current SourceMod snapshot: 1.12.0.6982
  • Current Metamod: Source snapshot: 1.12.0-dev+1167

Description

Bulk creation of SDKHooks on Linux servers seem to perform disproportionately worse than on an equivalent Windows server. I have verified this by creating identical Windows & Linux test servers on the same hardware.

With the test case provided below, peak frame time from round restart jumps from 290.30 ms to 3951.61 ms when the plugin is loaded on Linux. And from 175.21 ms to 251.07 ms when the plugin is loaded on Windows. I don't have exact values for when this happened on a live server, but it was enough to trigger the watchdog timer every time a round restarted on the affected map.

Problematic Code (or Steps to Reproduce)

The issue is noticeable when lots of entities are hooked in bulk, common plugin designs such as seen below can result in this happening at round start.

#include <sourcemod>
#include <sdkhooks>

public void OnEntityCreated(int entity, const char[] classname)
{
  SDKHook(entity, SDKHook_SpawnPost, Hook_SpawnPost);
}

void Hook_SpawnPost(int entity)
{
  // any code here
}

I have prepared a CS:GO test map that has 8193 entities (mostly lights) for easily testing this issue. If this test case sounds unrealistic, I assure you this exists in real maps, and is how I even discovered the issue initially.

Logs

  • Please attach in separate files: game output, library logs, kernel logs, and any other supporting information.
  • In case of a crash, please attach minidump or dump analyze output.

VProf output in all cases is from enabling sv_cheats and running endround once.
Linux with plugin
Linux without plugin
Windows with plugin
Windows without plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions