Hi,
I have come across a problem for us when using Artiq. We are taking about 4x (512,512) images per second in some experiments (atoms in optical tweezers) and we stream these to an archived dataset per image channel with append_to_dataset. After a few hours, this becomes many Gb, and this is replicated in the worker, the master, and any applet that subscribes to this channel's updates. The OS OOM killer comes up and kills some Artiq process.
This hurts in two ways: one, all the data is lost as the data isn't written until the end of the experiment, and secondly we want to see the data in the experiment as if it was HDF5 so we can analyse it 'normal python' while it's running and not wait many hours. Currently I have to keep a keen eye on the RAM consumption of the processes, the system, and ensure we don't run long routines.
My first thought was to solve this by incrementally backing up to HDF5 file, and having some datasets that get flushed to HDF5 as secondary storage. Or we could stream to it in the background with SWMR mode.
The problem with using SWMR mode is that it needs to know all the HDF5 keys beforehand I believe, which means we need to know all the dataset keys that will be pushed at the beginning of the experiment, which doesn't gel well with Artiq's current dataset API, where you can add anything to the dataset at any time.
Therefore we are left with writing entire HDF5 files. IT would also be nice if the solution allows replication across to a network drive with something like Lsyncd so that many people can access a copy of the data (potentially while the experiment is accumulating)
My current solution is to add a method self.checkpoint_datasets() to the environment that essentially checkpoints the state now. And also to introduce a new concept to the datasets of those that are written straight to disk with something like: self.create_stream_dataset(...) . Each checkpoint only writes the current data between the last checkpoint and the current checkpoint to a new HDF5 file and everything is linked together with HDF5 virtual datasets.
This gives you:
- Live saving of files that can be analysed while the experiment is run
- Still a 'fake' view of it being one single HDF5 file (although multiple are needed to implement this which I find inelegant)
- Backup in case experiment worker OR master crashes or is killed
- Ability to replicate checkpoints across network drives
I wondered if anyone had any thoughts on this kind of big data situation, that you can in most cases dump straight to disk, and backup, and live analysis on the saved data. I am looking to make a pull request soon. It did occur to me that maybe it was the intention that each RID was intended to be a unit of work that are accumulated and put together not necessarily a whole experiment, that doesn't gel well with my experiments that have feedback mechanisms.
Cheers,
Tom
P.S. Please point me if there's a better place to post these kinds of RFCs.