garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

[Linux DS 64] file.AsyncRead isn't Async

Open RaphaelIT7 opened this issue 1 year ago • 1 comments

Details

On Linux 64x file.AsyncRead doesn't seem to be Async.

My guess is that the filesystem's threadpool isn't started properly / same issue as https://github.com/Facepunch/garrysmod-issues/issues/5310 but I didn't verify this yet. https://github.com/perilouswithadollarsign/cstrike15_src/blob/master/filesystem/filesystem_async.cpp#L639

Steps to reproduce

  1. Start a Linux DS Server
  2. Run lua_run local a=SysTime() for k=1, 50 do file.AsyncRead("steamclient.so", "BASE_PATH", function() end) end print(SysTime()-a)
  3. Watch it freeze the main thread

RaphaelIT7 avatar Oct 15 '24 10:10 RaphaelIT7

Just verified it and it really seems like bEnableOnLinuxDedicatedServer is missing for the threadpool.

RaphaelIT7 avatar Oct 23 '24 03:10 RaphaelIT7

I have applied the proposed fix to the x86-64 beta.

robotboy655 avatar Nov 12 '24 19:11 robotboy655

Just tested it and it seems like it's still an active issue :/ What I literally do in holylib to fix it:

static bool hook_CThreadPool_Start(IThreadPool* pool, /*const*/ ThreadPoolStartParams_t& params, const char* pszName)
{
	if (!params.bEnableOnLinuxDedicatedServer)
	{
		params.bEnableOnLinuxDedicatedServer = true;

		if (g_pThreadPoolFixModule.InDebug())
			Msg("holylib - threadpoolfix: Manually fixed threadpool! (%s)\n", pszName); // NOTE: The filesystem threadpool has no name?
	}

	return detour_CThreadPool_Start.GetTrampoline<Symbols::CThreadPool_Start>()(pool, params, pszName);
}

So it must be missing somewhere, but maybe it's in another place?

RaphaelIT7 avatar Nov 12 '24 19:11 RaphaelIT7

I think I used the wrong define for it, please test again.

robotboy655 avatar Nov 12 '24 19:11 robotboy655

tested it again and it works

RaphaelIT7 avatar Nov 12 '24 19:11 RaphaelIT7