Skip to content
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-30614: Use RRD to update memory stats #3827

Merged
merged 7 commits into from
Mar 18, 2019
Merged

Conversation

psafont
Copy link
Member

@psafont psafont commented Mar 13, 2019

Memory statistics are now collected from rrd files in 2 new modules. These modules follow the same structure as ocaml/xapi/monitor_pvs_proxy.ml I'd like to reduce the amount of repeated/shared code in them, I'm open to suggestions.

Left to do: change how domain information is gathered from a string in ocaml/xapi/monitor_types.ml

Depends on xapi-project/xcp-rrdd#89

@coveralls
Copy link

coveralls commented Mar 13, 2019

Coverage Status

Coverage decreased (-0.009%) to 21.056% when pulling d68fc97 on psafont:CP-30614 into 7778c05 on xapi-project:master.

@robhoes
Copy link
Member

robhoes commented Mar 13, 2019

I haven't looked at this in detail yet, but my initial thought is that the duplication among the three monitor files could be reduced by using a functor. This is a good exercise in OCaml as well :)

@@ -60,7 +57,7 @@ let get_changes () =
| Rrd.VT_Float v -> int_of_float v
| Rrd.VT_Unknown -> -1
in
if ds.Ds.ds_name = Xapi_globs.pvs_proxy_status_ds_name then
if ds.Ds.ds_name = "pvscache_status" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you "unglobal" this? I think that it is good practice to have constant strings factored out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To open a conversation ;)

It's not a "xapi global" constant string at all, it gives the wrong impression that is shared or reused, at this point having it as a global provides indirection without benefit.

It might make sense to put it into xcp-idl and share the value with the plugin that generates the data. Same with the other metrics-related string constants.

@robhoes
Copy link
Member

robhoes commented Mar 13, 2019

And don't forget the final piece of the puzzle: removing the actual xenctrl dependency from the dune file :)

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the direction this is taking. As @robhoes said, a functor could make this more compact but I'm not sure it is worth it because you also need to accommodate the differences and quickly this becomes hard to read.

ocaml/xapi/monitor_dbcalls.ml Outdated Show resolved Hide resolved
ocaml/xapi/monitor_mem_host.ml Outdated Show resolved Hide resolved
ocaml/xapi/monitor_mem_vms.ml Outdated Show resolved Hide resolved
@psafont
Copy link
Member Author

psafont commented Mar 13, 2019

mem_vms and pvs_proxy are structurally very similar, mem_host is quite different and I do not think it's worth to try to put them along the others, maybe reusing the file-reading code would be enough.

@psafont psafont changed the title CP-30614: remove xenctrl dependency from xapi CP-30614: Use RRD to update memory stats Mar 13, 2019
Copy link
Contributor

@mseri mseri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of stringext where possible :)

ocaml/xapi/monitor_mem_host.ml Outdated Show resolved Hide resolved
ocaml/xapi/monitor_mem_vms.ml Outdated Show resolved Hide resolved
ocaml/xapi/monitor_pvs_proxy.ml Outdated Show resolved Hide resolved
ocaml/xapi/monitor_types.ml Outdated Show resolved Hide resolved
@psafont psafont force-pushed the CP-30614 branch 2 times, most recently from 373fd2c to 7bcdc54 Compare March 14, 2019 10:33
@lindig
Copy link
Contributor

lindig commented Mar 18, 2019

Is this ready to be merged?

@psafont
Copy link
Member Author

psafont commented Mar 18, 2019

I think so, @robhoes might want to take another look at it

module Lstext = Stdext.Listext.List
module Mcache = Monitor_dbcalls_cache

module D = Debug.Make(struct let name = "monitor_mem_vms" end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong name string here.

Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good and am happy to merge this now. However, I think that we should optimise this a little further in a follow-up PR. The performance of these functions is important, because the run every 5 s.

For example, we now call Monitor_types.find_rrd_files three times, which does the same directory listing each time. I wonder if it is possible to make the three monitor files even more similar, and merge them into one. I know that, for example, the host-memory one is different in the way the cache works, because it is using single values rather than hash tables. However, we could still decide to use a hash table for those as well. I don't see many fundamental differences, especially in the get_changes () functions.

separate the metrics directory name from pvs proxy metrics.
remove variable that's in practice internal to the filtering method for
pvs.
rename the pvsproxy variable so it is named like other metrics
variables.

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
on get_changes differentiate between filtering and transforming the
data.
On update consistently use pipelines instead of using variable declaration
and using ifs.

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
also removed opens from monitor_types

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
This allows to share the cache between several readers

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
this way it can be shared with other dss file readers

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
This remove a xenctrl usage from xapi.
Both VM and Host statistics for memory got moved to their respective
files. They more or less follow the same structure as monitor_pvs_proxy

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
@robhoes robhoes merged commit 6493dd2 into xapi-project:master Mar 18, 2019
@psafont psafont deleted the CP-30614 branch March 19, 2019 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants