auto_shutdown.py optimisation #1715

issue Garrysoon openend this issue on July 30, 2025
  1. Garrysoon commented at 8:00 pm on July 30, 2025: none

    Now the timer goes off every second . This is normal, but if the auto-off is 5 minutes (300 seconds), then 300 calls for one action is excessive.

    Instead of: period=1000, callback=seconds_counter

    Can: Start the timer for the entire time .time_out * 1000 On any action ( ) - stop and restart feed () This reduces the load on the CPU (fewer interrupts), saves energy .

    Example: def start_timer(self): if self.shutdown_time > 0: self.stop_timer() self.auto_shutdown_timer = Timer(Timer.TIMER1, Timer.CHANNEL0) self.auto_shutdown_timer.init( mode=Timer.ONE_SHOT, period=self.time_out * 1000, callback=self.on_timeout )

    def on_timeout(self, _): if self.ctx: self.ctx.clear() power_manager.shutdown()

    def feed(self): self.time_out = self.shutdown_time self.start_timer() #

    Advantages: No 300 calls per second - only one timer for the entire waiting time . Less load on the system. Faster reaction time - no need to wait for the next second

  2. Garrysoon closed this on Jul 30, 2025

  3. bitcoin-core locked this on Aug 1, 2025


Garrysoon


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-31 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me