Circo-dev / Circo.jl

A distributed computing platform, designed to scale to millions of nodes and providing metaphoric abstractions.
GNU Lesser General Public License v3.0
2 stars 1 forks source link

Measure the memory consumption of Actor instances #5

Closed tisztamo closed 4 years ago

tisztamo commented 4 years ago

Just to be sure that they are really cheap and provide numbers

tisztamo commented 4 years ago

56 bytes/actor instance:

julia> using Circo

julia> import Circo.onmessage

julia> machine = Machine()
Machine(SimpleComponentService(SimpleScheduler(SimpleComponentService(#= circular reference @-2 =#), WantlessComputation[], Dict{UInt64,WantlessComputation}(), 0, 1), SimpleActorScheduler(SimpleComponentService(#= circular reference @-2 =#), Circo.Actor[], Dict{UInt64,Circo.Actor}(), DataStructures.Queue{AbstractMessage}(Deque [AbstractMessage[]]))))

julia> varinfo()
  name                    size summary
  –––––––––––––––– ––––––––––– –––––––
  Base                         Module 
  Core                         Module 
  InteractiveUtils 159.200 KiB Module 
  Main                         Module 
  ans                9.195 KiB Machine
  machine            9.195 KiB Machine

julia> actorids=Array{ComponentId}(undef, 0)
0-element Array{UInt64,1}

julia> mutable struct SimpleActor <: Component
           id::ComponentId
           SimpleActor() = new(rand(ComponentId))
       end

julia> function onmessage(service, me::SimpleActor, message::Message{String})
           println("Actor #$(id(me)) got message $(body(message))")
       end
onmessage (generic function with 2 methods)

julia> for i in 1:1000000
           a = SimpleActor()
           push!(actorids, id(a))
           spawn(machine, a)
       end

julia> varinfo()
  name                    size summary                        
  –––––––––––––––– ––––––––––– –––––––––––––––––––––––––––––––
  Base                         Module                         
  Core                         Module                         
  InteractiveUtils 159.200 KiB Module                         
  Main                         Module                         
  SimpleActor        192 bytes DataType                       
  actorids           7.629 MiB 1000000-element Array{UInt64,1}
  ans                  0 bytes Nothing                        
  machine           56.897 MiB Machine                        

julia> for i=1:10
           machine(Message{String}(0, actorids[i], "Hello"))
       end
Actor #5603801488497289240 got message Hello
Actor #13699204526460003800 got message Hello
Actor #12268709501019422149 got message Hello
Actor #11605322855894257765 got message Hello
Actor #11890435643073587253 got message Hello
Actor #12339469059590917235 got message Hello
Actor #7133887944402902878 got message Hello
Actor #2355552806164298641 got message Hello
Actor #17128788734511638250 got message Hello
Actor #11474921271384446978 got message Hello