-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Motivation / Current Behaviour
Storing pointers to persons and locations in the ABM is convenient for programming, since it reduces the number of function arguments. But storing indices and only passing the actual objects when needed is much more flexible. Apart from performance improvements, it would also enable e.g. copying the World.
Two major performance problems that are caused by storing pointers:
- Adding and removing persons during migration is expensive and requires a mutex for multithreading
- iterating is slower because of reduced locality.
Enhancement description
Persons don't store a pointer to locations. Instead they store an index, the location object is passed by the World as a function argument when necessary.
Locations don't store persons at all. When some accumulation of persons per Location is necessary, this should be done by iterating over all persons and caching the result. This requires less synchronization. (It might become necessary later for the locations to store indices to its persons. This can be added later.)
The world can store the locations and persons directly and doesn't need unique_ptr.
Additional context
No response
Checklist
- Attached labels, especially loc:: or model:: labels.
- Linked to project
Metadata
Metadata
Assignees
Labels
Type
Projects
Status