-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP-52709: use timeslices shorter than 50ms #6177
base: feature/perf
Are you sure you want to change the base?
Changes from 1 commit
27018c1
4d1b7d2
764cbf1
b30e768
572559c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(library | ||
(name xapi_timeslice) | ||
(package xapi) | ||
(package xapi-idl) | ||
(libraries threads.posix mtime mtime.clock.os) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
unix | ||
uri | ||
uuidm | ||
xapi_timeslice | ||
xapi-backtrace | ||
xapi-consts | ||
xapi-log | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,25 @@ let setify = | |
in | ||
loop [] | ||
|
||
(** How long to let an OCaml thread run, before | ||
switching to another thread. | ||
This needs to be as small as possible to reduce latency. | ||
|
||
Too small values reduce performance due to context switching overheads | ||
|
||
4ms = 1/HZ in Dom0 seems like a good default, | ||
a better value will be written by a boot time service. | ||
*) | ||
let timeslice = ref 0.05 | ||
|
||
let apply_timeslice () = | ||
let interval = !timeslice in | ||
D.debug "Setting timeslice to %.3fs" interval ; | ||
if interval >= 0.05 then | ||
D.debug "Timeslice same as or larger than default: not setting" | ||
else | ||
Xapi_timeslice.Timeslice.set interval | ||
|
||
let common_options = | ||
[ | ||
( "use-switch" | ||
|
@@ -236,6 +255,11 @@ let common_options = | |
, (fun () -> !config_dir) | ||
, "Location of directory containing configuration file fragments" | ||
) | ||
; ( "timeslice" | ||
, Arg.Set_float timeslice | ||
, (fun () -> Printf.sprintf "%.3f" !timeslice) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure seconds is the best unit here when we mostly talk about milliseconds. However, this has enough resolution down to 1ms. |
||
, "timeslice in seconds" | ||
) | ||
] | ||
|
||
let loglevel () = !log_level | ||
|
@@ -454,6 +478,7 @@ let configure_common ~options ~resources arg_parse_fn = | |
failwith (String.concat "\n" lines) | ||
) | ||
resources ; | ||
apply_timeslice () ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would |
||
Sys.set_signal Sys.sigpipe Sys.Signal_ignore | ||
|
||
let configure ?(argv = Sys.argv) ?(options = []) ?(resources = []) () = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then where is
Xapi_timeslice.Timeslice.set
called for the default case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you mean the OCaml default of 50 ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the default timeslice is always there, this is in addition to that, it is not possible to turn off the default 50 ms switching.
I should probably document that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the idea is to add additional yields; would suggest to add
__FUNCTION__
to log messages.