From 4c2c296583e85a92b85e01d276e748b6989d58a2 Mon Sep 17 00:00:00 2001 From: ms2008 Date: Mon, 13 May 2024 11:45:08 +0800 Subject: [PATCH 1/2] docs(readme): add a note for the minimal resolution limitations --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ac10b8021..bf76dd3a8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ A scalable timer library for OpenResty. ## Status -This library is currently considered experimental. +This library is currently considered experimental. Note that timer-ng can only manage timer tasks with `delay` settings greater than or equal to `resolution` currently, otherwise those timers will fallback to OpenResty's native timer to be executed, which is out of timer-ng's timer pool limitation. And the current minimum value for `resolution` is `100ms`. + ## Synopsis @@ -69,7 +70,7 @@ http { ## Description This system is based on the timer wheel algorithm. -which uses the small number of timers +which uses the small number of timers created by OpenResty API `ngx.timer.at` to manage a large number of timed tasks. In other words, it can reduce the number of fake requests. @@ -97,7 +98,7 @@ The following information will be recorded in debug mode. * The timers that are running * Timers that are queued -In debug mode, +In debug mode, you can call [stats()](#stats) to get the raw data needed to generate the flamegraph. @@ -290,7 +291,7 @@ Get the statistics of the system. * `options`: * `verbose`: If `true`, the statistics for each timer will be returned, defualt `false`. - * `flamegraph`: If `true` and `verbose == true`, the raw data of flamegraph will be returned, + * `flamegraph`: If `true` and `verbose == true`, the raw data of flamegraph will be returned, you can run `flamegraph.pl > a.svg` to generate flamegraph, default `false`. For example: @@ -321,13 +322,13 @@ local flamegraph = info.flamegraph -- ref https://github.com/brendangregg/FlameGraph -for timer_name, timer in pairs(info.jobs) +for timer_name, timer in pairs(info.jobs) local is_running = timer.is_running local meta = timer.meta local stats = timer.stats local runs = timer.runs -- total number of runs - -- meta.name is an automatically generated string + -- meta.name is an automatically generated string -- that stores the location where the creation timer was created. -- Such as 'task.lua:56:start_background_task()' @@ -335,8 +336,8 @@ for timer_name, timer in pairs(info.jobs) stats = { - -- elapsed_time is a table that stores the - -- maximum, minimum, average and variance + -- elapsed_time is a table that stores the + -- maximum, minimum, average and variance -- of the time spent on each run of the timer (second). elapsed_time = { max = 100 From e4bba6f79d14ca22006ced1b4664e6674eb122c1 Mon Sep 17 00:00:00 2001 From: Qi Date: Mon, 13 May 2024 16:28:49 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf76dd3a8..8b17454cc 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,11 @@ A scalable timer library for OpenResty. ## Status -This library is currently considered experimental. Note that timer-ng can only manage timer tasks with `delay` settings greater than or equal to `resolution` currently, otherwise those timers will fallback to OpenResty's native timer to be executed, which is out of timer-ng's timer pool limitation. And the current minimum value for `resolution` is `100ms`. +This library is currently considered experimental. + +## Warning + +The timer-ng can only manage timer tasks with `delay` settings greater than or equal to `resolution` currently, otherwise, those timers will fallback to OpenResty's native timer to be executed, which is out of the concurrency control of the timer-ng. And the current minimum value for `resolution` is `100ms`. ## Synopsis