More Windows performance tweaks

This commit is contained in:
Empathic Qubit 2021-04-29 08:51:03 -04:00
parent 391ec2ae9e
commit e1b6f2937b
3 changed files with 23 additions and 16 deletions

View file

@ -6,7 +6,7 @@ local serpent = dofile(base.."/serpent.lua")
local libDeflate = dofile(base.."/LibDeflate.lua")
local hasThreads =
--not util.isWin and
not util.isWin and
config.NeatConfig.Threads > 1
local Runner = nil
if hasThreads then

View file

@ -76,7 +76,10 @@ runner.onLoad(function(filename)
)
end)
local waiter = util.startWaiting(inputFilePath)
local waiter = nil
if not isWin then
waiter = util.startWaiting(inputFilePath)
end
local function waitLoop()
if not first then
@ -95,7 +98,9 @@ local function waitLoop()
print('Waiting for input from master process')
if not isWin then
util.finishWaiting(waiter)
end
local inputData = nil
local ok = false
@ -149,7 +154,9 @@ local function waitLoop()
local inputFile = io.open(inputFilePath, "w")
inputFile:close()
if not isWin then
waiter = util.startWaiting(inputFilePath)
end
-- Write the result
local outFile = io.open(outputFilePath, "w")

View file

@ -67,8 +67,18 @@ return function()
onSaveHandler = {},
onLoadHandler = {},
poppets = {},
hostProcess = "lsnes",
}
if util.isWin then
_M.hostProcess = util.scrapeCmd('*l', 'powershell "(Get-WmiObject Win32_Process -Filter ProcessId=$((Get-WmiObject Win32_Process -Filter ProcessId=$((Get-WmiObject Win32_Process -Filter ProcessId=$PID).ParentProcessId)).ParentProcessId)").ExecutablePath')
if _M.hostProcess == nil or _M.hostProcess == "" then
_M.hostProcess = "lsnes-bsnes.exe"
end
else
-- FIXME Linux
end
_M.onRenderForm = function(handler)
end
@ -89,16 +99,6 @@ return function()
end
_M.run = function(species, generationIdx, genomeCallback, finishCallback)
local hostProcess = "lsnes"
if util.isWin then
hostProcess = util.scrapeCmd('*l', 'powershell "(Get-WmiObject Win32_Process -Filter ProcessId=$((Get-WmiObject Win32_Process -Filter ProcessId=$((Get-WmiObject Win32_Process -Filter ProcessId=$PID).ParentProcessId)).ParentProcessId)").ExecutablePath')
if hostProcess == nil or hostProcess == "" then
hostProcess = "lsnes-bsnes.exe"
end
else
-- FIXME Linux
end
local inputPrefix = tmpFileName..'_input_'
local outputPrefix = tmpFileName..'_output_'
@ -118,7 +118,7 @@ return function()
local outputFileName = outputPrefix..i
local inputFileName = inputPrefix..i
message(_M, hostProcess)
message(_M, _M.hostProcess)
local settingsDir = nil
if isWin then
@ -134,7 +134,7 @@ return function()
local waiter = util.startWaiting(outputFileName)
local cmd = '"'..hostProcess..'" "--rom='..config.ROM..'" --unpause "--lua='..base..'/runner-process.lua"'
local cmd = '"'.._M.hostProcess..'" "--rom='..config.ROM..'" --unpause "--lua='..base..'/runner-process.lua"'
local poppet = util.popenCmd(cmd, nil, envs)
table.insert(_M.poppets, poppet)