From fe79b0f40dd1efb913a2153524d5c204a70b2e96 Mon Sep 17 00:00:00 2001 From: Andrii Sultanov Date: Tue, 8 Oct 2024 11:25:06 +0100 Subject: [PATCH] CA-400124 - rrdd: only serialize transform when it's not default This saves on space, since only cpuX and cpu_avg datasources currently have transform=inverse, all the others have the default identity function specified. Signed-off-by: Andrii Sultanov --- ocaml/xcp-rrdd/lib/transport/base/rrd_json.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ocaml/xcp-rrdd/lib/transport/base/rrd_json.ml b/ocaml/xcp-rrdd/lib/transport/base/rrd_json.ml index b6d1095372..15f95e3de4 100644 --- a/ocaml/xcp-rrdd/lib/transport/base/rrd_json.ml +++ b/ocaml/xcp-rrdd/lib/transport/base/rrd_json.ml @@ -45,13 +45,13 @@ let ds_owner x = ) let ds_transform x = - ( "transform" - , match x with - | Rrd.Identity -> - string "identity" - | Rrd.Inverse -> - string "inverse" - ) + match x with + | Rrd.Identity -> + [] + (* This is the default when transform is absent, and not including it + makes the file smaller *) + | Rrd.Inverse -> + [("transform", string "inverse")] let bool b = string "%b" b (* Should use `Bool b *) @@ -72,7 +72,7 @@ let ds_to_json (owner, ds) = [ description ds.Ds.ds_description ; [ds_owner owner] - ; [ds_transform ds.Ds.ds_pdp_transform_function] + ; ds_transform ds.Ds.ds_pdp_transform_function ; ds_value ds.Ds.ds_value ; [ds_type ds.Ds.ds_type] ; [