I have a task, which I know how to code (in C#), but I know a simple implementation will not meet ALL my needs. So, I am looking for tricks which might meet ALL my needs.
- I am writing a simulation involving N number of entities interacting over time. 
- N will start at around 30 and move in to many thousands. - a. The number of entities will change during the course of the simulation.- b. I expect this will require each entity to have its own trace file. 
- Each Entity has a minimum of 20 parameters, up to millions; I want to track over time. - a. This will most likely required that we can’t keep all values in memory at all times. Some subset should be fine. - b. The number of parameters per entity will initially be fixed, but I can think of some test which would have the number of parameters slowing changing over time. 
- Simulation will last for millions of time steps and I need to keep every value for every parameter. 
- What I will be using these traces for: - a. Plotting a subset (configurable) of the parameters for a fixed amount of time from the current time step to the past. - i. Normally on the order of 300 time steps. ii. These plots are in real time while the simulation is running.- b. I will be using these traces to re-play the simulation, so I need to quickly access all the parameters at a give time step so I can quickly move to different times in the simulation. - i. This requires the values be stored in a file(s) which can be inspected/loaded after restarting the software. ii. Using a database is NOT an option.- c. I will be using the parameters for follow up analysis which I can’t define up front so a more flexible system is desirable. 
My initial thought:
- One class per entity which holds all the parameters. 
- Backed by a memory mapped file. 
- Only a fixed, but moving, amount of the file is mapped to main memory 
- A second memory mapped file which holds time indexes to main file for quicker access during re-playing of simulation. This may be very important because each entity file will represent a different time slice of the full simulation.