perlindgren / syncrim

17 stars 4 forks source link

Decouple clock number from size of history (Max history depth) #37

Open Freddo3000 opened 1 year ago

Freddo3000 commented 1 year ago

Having clock number tied to history causes issues on higher clock numbers, as it is effectively a memory leak. It would be better to keep it separate, and add a limit to how large the history size can grow before it starts discarding the oldest records. I also suggest that instead of clock being stored in GuiData it is instead fetched when needed from the simulator.

perlindgren commented 1 year ago

The reason to have clock in GuiData is that it provides a lens, so when changed components like the ProbeEdit knows that something has happened.

Regarding memory leak, I don't quite follow.

Freddo3000 commented 1 year ago

Regarding memory leak, I don't quite follow.

I mean that keeping an unlimited sized history might not be optimal, as it might cause issues if you for example leave the clock running in the background and forget about it, as it will endlessly grow.

perlindgren commented 1 year ago

Indeed, the simulator holds the history (as a Vec<...), it would be perfectly possible to limit the size and have it dropping oldest element, on enqueing a new. Maybe a double linked version would be better with cheap operations on both head and tail.

perlindgren commented 1 year ago

Components (and GUI elements) that holds internal state etc., is responsible for their own history management, essentially triggered by clock, un_clock and perhaps also reset (currently not implemented though).