diff --git a/src/README.md b/src/README.md index 3b31faf223..f178cfded5 100644 --- a/src/README.md +++ b/src/README.md @@ -89,13 +89,6 @@ For example: Move packets from input ports to output ports or to a network adapter. -— Method **myapp:relink** - -*Optional*. React to a changes in input/output links (`app.input` and -`app.output`). This method is called after a link reconfiguration but -before the next packets are processed. - - — Method **myapp:reconfig** *arg* *Optional*. Reconfigure the app with a new *arg*. If this method is not @@ -207,7 +200,23 @@ following keys are recognized: Returns monotonic time in seconds as a floating point number. Suitable for timers. +— Variable **engine.busywait** + +If set to true then the engine polls continuously for new packets to +process. This consumes 100% CPU and makes processing latency less +vulnerable to kernel scheduling behavior which can cause pauses of +more than one millisecond. + +Default: false + +— Variable **engine.Hz** + +Frequency at which to poll for new input packets. The default value is +'false' which means to adjust dynamically up to 100us during low +traffic. The value can be overridden with a constant integer saying +how many times per second to poll. +This setting is not used when engine.busywait is true. ## Link (core.link) diff --git a/src/README.md.src b/src/README.md.src index f4c200d213..c9abcd9680 100644 --- a/src/README.md.src +++ b/src/README.md.src @@ -216,7 +216,23 @@ following keys are recognized: Returns monotonic time in seconds as a floating point number. Suitable for timers. +— Variable **engine.busywait** +If set to true then the engine polls continuously for new packets to +process. This consumes 100% CPU and makes processing latency less +vulnerable to kernel scheduling behavior which can cause pauses of +more than one millisecond. + +Default: false + +— Variable **engine.Hz** + +Frequency at which to poll for new input packets. The default value is +'false' which means to adjust dynamically up to 100us during low +traffic. The value can be overridden with a constant integer saying +how many times per second to poll. + +This setting is not used when engine.busywait is true. ## Link (core.link) diff --git a/src/core/app.lua b/src/core/app.lua index f9ffb25644..84806f740c 100644 --- a/src/core/app.lua +++ b/src/core/app.lua @@ -55,6 +55,10 @@ Hz = false sleep = 0 maxsleep = 100 +-- busywait: If true then the engine will poll for new data in a tight +-- loop (100% CPU) instead of sleeping according to the Hz setting. +busywait = false + -- Return current monotonic time in seconds. -- Can be used to drive timers in apps. monotonic_now = false @@ -233,7 +237,7 @@ function main (options) repeat breathe() if not no_timers then timer.run() end - pace_breathing() + if not busywait then pace_breathing() end until done and done() if not options.no_report then report(options.report) end end