On Tue, Dec 23, 2008 at 8:04 AM, bOR_ <boris.sch...@gmail.com> wrote: > > * This variant seems to be light on the number of threads. My > population size is now a 1000 hosts, but I will probably run sims with > 10,000 and 100,000 hosts as well. Not knowing that much about how > threads work inside a machine, I worried about sending off a 100,000 > agents.
This is common misconception. The number of agents created does not map to the number of threads created, and neither does the number of of 'send's (though 'send-off's are a different story). Agents are just in-memory data objects, not threads, and don't even have much memory overhead. They are cheap to create, cheap to store. Nothing much is created when you 'send' either -- no new thread. A new entry may be added to a queue, but this is also very cheap. 'send' uses a thread pool that does not grow, but is based on the number of CPUs your machine has. If you have 2 CPUs and have called 'send' a thousand times in a row, you may have some deep queues that will take a while for the 2 or 3 threads to work through, but there will not be a thousand-times-worse thrashing or task-switching overhead, or anything ugly like that. In short, it's ok to have a lot of agents, and to queue up a lot of work for them. 'send-off' uses a different thread pool that does grow the more 'send-off's you do. I don't know its exact performance profile, but I would do a bit of testing before doing thousands of 'send-off's to thousands of agents. --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---