I’m running a simulation with 10000 agents in a continuous space. Even 4 time steps takes minutes… Netlogo can do a similar thing in milliseconds.
So of course I hit the profiler:
131╎131 @Base/dict.jl:279; ht_keyindex(::Dict{Symbol,Int64}, ::Symbol)
╎13763 @Base/task.jl:358; (::REPL.var"#26#27"{REPL.REPLBackend})()
╎ 13763 .../julia/stdlib/v1.4/REPL/src/REPL.jl:118; macro expansion
╎ 13763 .../julia/stdlib/v1.4/REPL/src/REPL.jl:86; eval_user_input(::Any, ::REPL.REPLBackend)
╎ 13763 @Base/boot.jl:331; eval(::Module, ::Any)
╎ 13763 @Revise/src/Revise.jl:1165; run_backend(::REPL.REPLBackend)
╎ 13763 ...julia/stdlib/v1.4/REPL/src/REPL.jl:86; eval_user_input(::Any, ::REPL.REPLBackend)
╎42450 @Base/task.jl:444; task_done_hook(::Task)
╎ 42450 @Base/task.jl:709; wait
42449╎ 42450 @Base/task.jl:702; poptaskref(::Base.InvasiveLinkedListSynchronized{Task})
╎1 @Agents/src/simulations/collect.jl:62; (::Agents.var"#run!##kw")(::NamedTuple{(:adata, :mdata)...
╎ 1 @Agents/src/simulations/collect.jl:70; #run!#96
╎ 1 @Agents/src/simulations/collect.jl:86; (::Agents.var"#_run!##kw")(::NamedTuple{(:adata, :mdata...
╎ 1 @Agents/src/simulations/collect.jl:103; _run!(::AgentBasedModel{COVPerson,ContinuousSpace{type...
╎ 1 @Agents/src/simulations/step.jl:44; step!(::AgentBasedModel{COVPerson,ContinuousSpace{type...
╎ 1 REPL[130]:31; stepcovmodel!(::AgentBasedModel{COVPerson,ContinuousS...
╎1 @Agents/src/simulations/step.jl:44; step!(::AgentBasedModel{COVPerson,ContinuousSpace{typeo...
1╎ 1 @Base/array.jl:678; _collect(::SubArray{COVPerson,1,Array{COVPerson,1},Tupl...
Total snapshots: 70378
I did 4 timesteps, and 10k agents, so the fact that it calls poptaskref 42449 times suggests to me that for every timestep, it pushes a task for every agent… This is incredibly inefficient and it’s spending all its time pushing and popping tasks… Of course I could be wrong.
It seems clear that a bunch of time is spent doing something before my calculation takes hold… I think this may be Revise or something? I’m not sure…
Here’s a profile with only 1000 agents… the big bar along the bottom is calls to poptaskref
Ok, I’m beginning to think that the lowest level calls are actually something to do with the repl/Revise… I’m still not sure why so many samples have nothing above them… All the “actual computing” comes in the last 25% of samples?
In any case, I think I’m on my way to understanding what’s making this slow. Seems like there’s a LOT of allocations, related to the way that I check for interactions between agents.