Hi Balena team,
is it possible to create swap files inside a specific container? I could not find any documentation about it.
I know they are slow but sadly necessary for my application
Further more these parts of the documentation seem to be kind of conflicting (i know docker-compose is not the docker deamon):
The docer-compose documentation list memswap_limit
as known unsupported
But https://github.com/balena-os/balena-engine-cli/blob/master/docs/reference/run.md lists it as run time option --memory-swap=""
Hi @Langhalsdino,
We currently do not support the memswap_limit
docker-compose field and do not encourage using swap on IoT devices in general.
The main reason is that using swap can wear the storage medium of the device really quickly, especially if it is using an SD card.
BalenaOS is using a readonly filesystem for most of its parts exactly for this reason.
Could you provide some extra info about your use case and the reason that using in container swap files is required?
I would like to open an internal feature request issue for this and add it to the list of features to consider.
In the mean time, even though we do not officially support swap files, I can point you to a blog post of ours, where we explain how we managed to get a resource heavy application run using a system level swap file:
Keep in mind though that the balenaFin has an industrial grade eMMC storage and also that this was an experiment from our side that we didn’t evaluate how it would work for long periods of time.
Kind regards,
Thodoris
Thanks for the quick reply.
I completely agree that working with swap files in production is not a good idea.
Our usecase is completly development driven. We work with images / videostreams and Neuronal Networks on the Nvidia Jetson Nano. Since tensorflow is allocating a big chunk of the shared memory (gpu & cpu shared) our first naive approaches some times do not fit into the left memory of the jetson nano. Therefore the container gets killed by the balena engine. Since debugging and profiling our code is a bit hard, when it gets kill as soon as we start it, we would like to have an option to enable swap memory for debugging and profiling purposes.
But if you have any other ideas how to enable debugging and profiling, i am happy to try them out
Hopefully that blog post helps you out as far as getting it to work on your dev devices. Let us know what you encounter though.