more updates

This commit is contained in:
Ryan Ward 2019-02-01 10:43:00 -05:00
parent 0fd604e356
commit 20647f4738
4 changed files with 88 additions and 89 deletions

View File

@ -54,6 +54,8 @@ Fixed:
- Found an issue with the rockspec which is due to the networkManager additon. The net Library and the multi Library are now codependent if using that feature. Going forward you will have to now install the network library separately - Found an issue with the rockspec which is due to the networkManager additon. The net Library and the multi Library are now codependent if using that feature. Going forward you will have to now install the network library separately
- Insane proformance bug found in the networkManager file, where each connection to a node created a new thread (VERY BAD) If say you connected to 100s of threads, you would lose a lot of processing power due to a bad implementation of this feature. But it goes futhur than this, the net library also creates a new thread for each connection made, so times that initial 100 by about 3, you end up with a system that quickly eats itself. I have to do tons of rewriting of everything. Yet another setback for the 13.0.0 release - Insane proformance bug found in the networkManager file, where each connection to a node created a new thread (VERY BAD) If say you connected to 100s of threads, you would lose a lot of processing power due to a bad implementation of this feature. But it goes futhur than this, the net library also creates a new thread for each connection made, so times that initial 100 by about 3, you end up with a system that quickly eats itself. I have to do tons of rewriting of everything. Yet another setback for the 13.0.0 release
- Fixed an issue where any argument greater than 256^2/65536 bytes is sent the networkmanager would soft crash. This was fixed by increading the limit to 256^4/4294967296 bytes. The fix was changing a 2 to a 4. Arguments greater than 256^4 would be impossible in 32 bit lua, and highly unlikely even in lua 64 bit. Perhaps someone is reading an entire file into ram and then sending the entire file that they read over a socket for some reason all at once!? - Fixed an issue where any argument greater than 256^2/65536 bytes is sent the networkmanager would soft crash. This was fixed by increading the limit to 256^4/4294967296 bytes. The fix was changing a 2 to a 4. Arguments greater than 256^4 would be impossible in 32 bit lua, and highly unlikely even in lua 64 bit. Perhaps someone is reading an entire file into ram and then sending the entire file that they read over a socket for some reason all at once!?
- Fixed an issue with processors not properly destroying objects within them and not being destroyable themselves
- Fixed a bug where pause and resume would duplicate objects! Not good
Added: Added:
- Documentation, the purpose of 13.0.0, orginally going to be 12.2.3, but due to the amount of bugs and features I added couldn't become that. I actually still did my tests in the 12.2.3 branch in github. - Documentation, the purpose of 13.0.0, orginally going to be 12.2.3, but due to the amount of bugs and features I added couldn't become that. I actually still did my tests in the 12.2.3 branch in github.

View File

@ -34,7 +34,6 @@ multi.ender = {}
multi.Children = {} multi.Children = {}
multi.Active = true multi.Active = true
multi.fps = 60 multi.fps = 60
multi.Id = -1
multi.Type = "mainprocess" multi.Type = "mainprocess"
multi.Rest = 0 multi.Rest = 0
multi._type = type multi._type = type
@ -138,7 +137,7 @@ function multi:enableLoadDetection()
while not stop do while not stop do
temp:uManager() temp:uManager()
end end
temp:__Destroy() temp:Destroy()
multi.maxSpd = stop multi.maxSpd = stop
end end
local MaxLoad = nil local MaxLoad = nil
@ -335,19 +334,28 @@ function multi:getTasksDetails(t)
str = { str = {
{"Type","Uptime","Priority","TID"} {"Type","Uptime","Priority","TID"}
} }
local count = 0
for i,v in pairs(self.Mainloop) do for i,v in pairs(self.Mainloop) do
local name = v.Name or "" local name = v.Name or ""
if name~="" then if name~="" then
name = " <"..name..">" name = " <"..name..">"
end end
count = count + 1
table.insert(str,{v.Type:sub(1,1):upper()..v.Type:sub(2,-1)..name,multi.Round(os.clock()-v.creationTime,3),self.PriorityResolve[v.Priority],i}) table.insert(str,{v.Type:sub(1,1):upper()..v.Type:sub(2,-1)..name,multi.Round(os.clock()-v.creationTime,3),self.PriorityResolve[v.Priority],i})
end end
if count == 0 then
table.insert(str,{"Currently no processes running!","","",""})
end
local s = multi.AlignTable(str) local s = multi.AlignTable(str)
dat = "" dat = ""
for i=1,#multi.scheduler.Threads do if multi.scheduler then
dat = dat .. "<THREAD: "..multi.scheduler.Threads[i].Name.." | "..os.clock()-multi.scheduler.Threads[i].creationTime..">\n" for i=1,#multi.scheduler.Threads do
dat = dat .. "<THREAD: "..multi.scheduler.Threads[i].Name.." | "..os.clock()-multi.scheduler.Threads[i].creationTime..">\n"
end
return "Load on "..({[true]="SubProcess<"..(self.Name or "Unnamed")..">",[false]="MainProcess"})[self.Type=="process"]..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: "..#multi.scheduler.Threads.."\n\n"..s.."\n\n"..dat
else
return "Load on "..({[true]="SubProcess<"..(self.Name or "Unnamed")..">",[false]="MainProcess"})[self.Type=="process"]..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: 0\n\n"..s
end end
return "Load on manager: "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: "..#multi.scheduler.Threads.."\n\n"..s.."\n\n"..dat
elseif t == "t" or t == "table" then elseif t == "t" or t == "table" then
str = {ThreadCount = #multi.scheduler.Threads,MemoryUsage = math.ceil(collectgarbage("count")).." KB"} str = {ThreadCount = #multi.scheduler.Threads,MemoryUsage = math.ceil(collectgarbage("count")).." KB"}
str.threads = {} str.threads = {}
@ -503,8 +511,12 @@ function multi:Pause()
print("You cannot pause the main process. Doing so will stop all methods and freeze your program! However if you still want to use multi:_Pause()") print("You cannot pause the main process. Doing so will stop all methods and freeze your program! However if you still want to use multi:_Pause()")
else else
self.Active=false self.Active=false
if self.Parent.Mainloop[self.Id]~=nil then local loop = self.Parent.Mainloop
table.remove(self.Parent.Mainloop,self.Id) for i=1,#loop do
if loop[i] == self then
table.remove(loop,i)
break
end
end end
end end
return self return self
@ -517,9 +529,8 @@ function multi:Resume()
c[i]:Resume() c[i]:Resume()
end end
else else
if self:isPaused() then if self.Active==false then
table.insert(self.Parent.Mainloop,self) table.insert(self.Parent.Mainloop,self)
self.Id=#self.Parent.Mainloop
self.Active=true self.Active=true
end end
end end
@ -556,8 +567,10 @@ function multi:create(ref)
multi.OnObjectCreated:Fire(ref,self) multi.OnObjectCreated:Fire(ref,self)
end end
function multi:setName(name) function multi:setName(name)
self.Name = name self.Name = name
end return self
end
multi.SetName = multi.setName
--Constructors [CORE] --Constructors [CORE]
function multi:newBase(ins) function multi:newBase(ins)
if not(self.Type=='mainprocess' or self.Type=='process' or self.Type=='queue') then error('Can only create an object on multi or an interface obj') return false end if not(self.Type=='mainprocess' or self.Type=='process' or self.Type=='queue') then error('Can only create an object on multi or an interface obj') return false end
@ -573,7 +586,6 @@ function multi:newBase(ins)
c.funcTMR={} c.funcTMR={}
c.ender={} c.ender={}
c.important={} c.important={}
c.Id=0
c.Act=function() end c.Act=function() end
c.Parent=self c.Parent=self
c.held=false c.held=false
@ -597,7 +609,6 @@ function multi:newProcessor(file)
c.Garbage={} c.Garbage={}
c.Children={} c.Children={}
c.Active=false c.Active=false
c.Id=-1
c.Rest=0 c.Rest=0
c.Jobs={} c.Jobs={}
c.queue={} c.queue={}
@ -621,7 +632,8 @@ function multi:newProcessor(file)
return self return self
end end
function c:setName(name) function c:setName(name)
c.Name = name c.l.Name = name
return self
end end
function c:Pause() function c:Pause()
if self.l then if self.l then
@ -637,6 +649,18 @@ function multi:newProcessor(file)
self:__Destroy() self:__Destroy()
end end
end end
function c:Destroy()
if self == c then
self.l:Destroy()
else
for i = #c.Mainloop,1,-1 do
if c.Mainloop[i] == self then
table.remove(c.Mainloop,i)
break
end
end
end
end
if file then if file then
self.Cself=c self.Cself=c
loadstring('local process=multi.Cself '..io.open(file,'rb'):read('*all'))() loadstring('local process=multi.Cself '..io.open(file,'rb'):read('*all'))()
@ -836,7 +860,6 @@ function multi:newJob(func,name)
end end
c.Active=true c.Active=true
c.func={} c.func={}
c.Id=0
c.Parent=self c.Parent=self
c.Type='job' c.Type='job'
c.trigfunc=func or function() end c.trigfunc=func or function() end
@ -1578,7 +1601,6 @@ function multi:newThreadedProcess(name)
ct.Active=true ct.Active=true
ct.func={} ct.func={}
ct.ender={} ct.ender={}
ct.Id=0
ct.Act=function() end ct.Act=function() end
ct.Parent=self ct.Parent=self
ct.held=false ct.held=false
@ -1589,13 +1611,11 @@ function multi:newThreadedProcess(name)
c.Parent=self c.Parent=self
c.Active=true c.Active=true
c.func={} c.func={}
c.Id=0
c.Type='threadedprocess' c.Type='threadedprocess'
c.Mainloop={} c.Mainloop={}
c.Garbage={} c.Garbage={}
c.Children={} c.Children={}
c.Active=true c.Active=true
c.Id=-1
c.Rest=0 c.Rest=0
c.updaterate=.01 c.updaterate=.01
c.restRate=.1 c.restRate=.1
@ -1664,7 +1684,6 @@ function multi:newHyperThreadedProcess(name)
ct.Active=true ct.Active=true
ct.func={} ct.func={}
ct.ender={} ct.ender={}
ct.Id=0
ct.Act=function() end ct.Act=function() end
ct.Parent=self ct.Parent=self
ct.held=false ct.held=false
@ -1689,13 +1708,11 @@ function multi:newHyperThreadedProcess(name)
c.Parent=self c.Parent=self
c.Active=true c.Active=true
c.func={} c.func={}
c.Id=0
c.Type='hyperthreadedprocess' c.Type='hyperthreadedprocess'
c.Mainloop={} c.Mainloop={}
c.Garbage={} c.Garbage={}
c.Children={} c.Children={}
c.Active=true c.Active=true
c.Id=-1
c.Rest=0 c.Rest=0
c.updaterate=.01 c.updaterate=.01
c.restRate=.1 c.restRate=.1
@ -2052,11 +2069,12 @@ function multi:uManager(settings)
end end
function multi:uManagerRef(settings) function multi:uManagerRef(settings)
if self.Active then if self.Active then
if ncount ~= 0 then if next then
for i = 1, ncount do local DD = table.remove(next,1)
next[i]() while DD do
DD()
DD = table.remove(next,1)
end end
ncount = 0
end end
local Loop=self.Mainloop local Loop=self.Mainloop
local PS=self local PS=self
@ -2236,8 +2254,6 @@ function multi:ToString()
important=self.important, important=self.important,
Active=self.Active, Active=self.Active,
ender=self.ender, ender=self.ender,
-- IDK if these need to be present...
-- Id=self.Id,
held=self.held, held=self.held,
} }
else else
@ -2248,8 +2264,6 @@ function multi:ToString()
funcTMR=self.funcTMR, funcTMR=self.funcTMR,
important=self.important, important=self.important,
ender=self.ender, ender=self.ender,
-- IDK if these need to be present...
-- Id=self.Id,
held=self.held, held=self.held,
} }
end end

View File

@ -42,6 +42,7 @@ local CMD_CONSOLE = 0x0B
local char = string.char local char = string.char
local byte = string.byte local byte = string.byte
-- Process to hold all of the networkManager's muilt objects
-- Helper for piecing commands -- Helper for piecing commands
local function pieceCommand(cmd,...) local function pieceCommand(cmd,...)
@ -440,14 +441,11 @@ function multi:newMaster(settings) -- You will be able to have more than one mas
name = self:getRandomNode() name = self:getRandomNode()
end end
if name==nil then if name==nil then
multi:newThread("Network Thread Manager",function(loop) multi:newEvent(function() return name~=nil end):OnEvent(function(evnt)
while true do self:sendTo(name,char(CMD_TASK)..len..aData..len2..fData)
if name~=nil then evnt:Destroy()
self:sendTo(name,char(CMD_TASK)..len..aData..len2..fData) end):SetName("DelayedSendTask"):SetName("DelayedSendTask"):SetTime(8):OnTimedOut(function(self)
thread.kill() self:Destroy()
end
thread.sleep(.1)
end
end) end)
else else
self:sendTo(name,char(CMD_TASK)..len..aData..len2..fData) self:sendTo(name,char(CMD_TASK)..len..aData..len2..fData)
@ -462,14 +460,11 @@ function multi:newMaster(settings) -- You will be able to have more than one mas
name = "NODE_"..name name = "NODE_"..name
end end
if self.connections[name]==nil then if self.connections[name]==nil then
multi:newThread("Node Data Link Controller",function(loop) multi:newEvent(function() return self.connections[name]~=nil end):OnEvent(function(evnt)
while true do self.connections[name]:send(data)
if self.connections[name]~=nil then evnt:Destroy()
self.connections[name]:send(data) end):SetName("DelayedSendTask"):SetTime(8):OnTimedOut(function(self)
thread.kill() self:Destroy()
end
thread.sleep(.1)
end
end) end)
else else
self.connections[name]:send(data) self.connections[name]:send(data)

View File

@ -1,52 +1,40 @@
package.path="?/init.lua;?.lua;"..package.path package.path="?/init.lua;?.lua;"..package.path
multi = require("multi") multi = require("multi")
--~ local GLOBAL,THREAD = require("multi.integration.lanesManager").init() local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
--~ nGLOBAL = require("multi.integration.networkManager").init() nGLOBAL = require("multi.integration.networkManager").init()
--~ local a local a
--~ function multi:setName(name) function multi:setName(name)
--~ self.Name = name self.Name = name
--~ end end
--~ local clock = os.clock local clock = os.clock
--~ function sleep(n) -- seconds function sleep(n) -- seconds
--~ local t0 = clock() local t0 = clock()
--~ while clock() - t0 <= n do end while clock() - t0 <= n do end
--~ end end
--~ master = multi:newMaster{ master = multi:newMaster{
--~ name = "Main", -- the name of the master name = "Main", -- the name of the master
--~ --noBroadCast = true, -- if using the node manager, set this to true to avoid double connections --noBroadCast = true, -- if using the node manager, set this to true to avoid double connections
--~ managerDetails = {"192.168.1.4",12345}, -- the details to connect to the node manager (ip,port) managerDetails = {"192.168.1.4",12345}, -- the details to connect to the node manager (ip,port)
--~ } }
--~ master.OnError(function(name,err) master.OnError(function(name,err)
--~ print(name.." has encountered an error: "..err) print(name.." has encountered an error: "..err)
--~ end) end)
--~ local connlist = {} local connlist = {}
--~ multi:newThread("NodeUpdater",function() multi:newThread("NodeUpdater",function()
--~ while true do
--~ thread.sleep(1)
--~ for i=1,#connlist do
--~ conn = master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
--~ end
--~ end
--~ end)
--~ master.OnNodeConnected(function(name)
--~ table.insert(connlist,name)
--~ end)
--~ multi.OnError(function(...)
--~ print(...)
--~ end)
--~ for i=1,20 do
--~ multi:newLoop(function()
--~ for i=1,500 do
--~ --
--~ end
--~ end)
--~ end
multi:newThread("Test",function()
while true do while true do
thread.sleep(1) thread.sleep(.1)
print(multi:getTasksDetails()) for i=1,#connlist do
conn = master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
end
end end
end) end)
master.OnNodeConnected(function(name)
table.insert(connlist,name)
end)
multi.OnError(function(...)
print(...)
end)
multi:mainloop{ multi:mainloop{
protect = false protect = false
} }