Off and on again: Modeling and optimizing intermittent computing systems