From f9949084ade57a7a7c97d8a0933cb20005ca0ea0 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 29 Oct 2015 15:18:05 +0100 Subject: [PATCH 1/3] Fix slowdown in rendering caused by #119 --- graphite_api/render/datalib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphite_api/render/datalib.py b/graphite_api/render/datalib.py index b61e3ca..fe07605 100644 --- a/graphite_api/render/datalib.py +++ b/graphite_api/render/datalib.py @@ -140,7 +140,7 @@ def fetchData(requestContext, pathExprs): # Group nodes that support multiple fetches for pathExpr in pathExprs: - for node in app.store.find(pathExpr): + for node in app.store.find(pathExpr, startTime, endTime): if not node.is_leaf: continue path_to_exprs[node.path].append(pathExpr) From 1bd634213ef0fc1291d6ef7769321bbc60bf6bea Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 4 Nov 2015 16:34:29 +0100 Subject: [PATCH 2/3] Don't append duplicate nodes returned by the finder --- graphite_api/render/datalib.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graphite_api/render/datalib.py b/graphite_api/render/datalib.py index fe07605..9301abd 100644 --- a/graphite_api/render/datalib.py +++ b/graphite_api/render/datalib.py @@ -130,7 +130,6 @@ def fetchData(requestContext, pathExprs): # Convert to list if given single path if not isinstance(pathExprs, list): pathExprs = [pathExprs] - pathExprs = set(pathExprs) data_store = DataStore() multi_nodes = defaultdict(list) @@ -143,11 +142,12 @@ def fetchData(requestContext, pathExprs): for node in app.store.find(pathExpr, startTime, endTime): if not node.is_leaf: continue + if node.path not in path_to_exprs: + if hasattr(node, '__fetch_multi__'): + multi_nodes[node.__fetch_multi__].append(node) + else: + single_nodes.append(node) path_to_exprs[node.path].append(pathExpr) - if hasattr(node, '__fetch_multi__'): - multi_nodes[node.__fetch_multi__].append(node) - else: - single_nodes.append(node) # Multi fetches for finder in app.store.finders: From 94fe4929c8042c736ce3b6cf6468dd1bf6072f16 Mon Sep 17 00:00:00 2001 From: Mark Bell Date: Wed, 18 Nov 2015 20:23:06 -0500 Subject: [PATCH 3/3] Fix regression in multi fetch handling --- graphite_api/render/datalib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphite_api/render/datalib.py b/graphite_api/render/datalib.py index fe07605..dc7c3df 100644 --- a/graphite_api/render/datalib.py +++ b/graphite_api/render/datalib.py @@ -159,7 +159,7 @@ def fetchData(requestContext, pathExprs): time_info, series = finder.fetch_multi(nodes, startTime, endTime) for path, values in series.items(): data_store.add_data(path, time_info, values, - path_to_exprs[node.path]) + path_to_exprs[path]) # Single fetches fetches = [