Opened 21 months ago

#2645 new enhancement

Fight App Nap and the like

Reported by: jogger Owned by:
Priority: major Milestone: undecided
Component: router/general Version: 0.9.43
Keywords: Cc:
Parent Tickets: Sensitive: no


As noted elsewhere MacOS and Windoze employ strategies like App Nap, timer coalescing and the like in order to batch thread executions together in order not to frequently heat up the CPU. I wrote a couple of timing exercises to confirm this. Most notable results: sleep(20) 11% late on Mac, 60% on Win. sleep(50) 4% late on Mac, 30% on Win. As the CPUs are fast i2p is put to rest frequently causing significant latency.

In particular those OSes might not let you go, if kernel timers fire, or network traffic or a thread is ready. On the other hand they will give you 100% if you do not give up the CPU. On the Mac if you occupy one core with e.g. ffmpeg, App Nap is suspended for the entire machine.

This can be addressed by two simple measures:
Despite kernel timers being a bit late one could set the max wait for NTCP Pumper and Packet Pusher to 20 ms to get frequent wakeup.
Also sizing all thread pools to 1 helps occupying the CPU. Iterating over stuff takes a little bit of time but is more than offset by all parallel threads running without delay during that time.


Change History (0)

Note: See TracTickets for help on using tickets.