89 Commits

Author SHA1 Message Date
Bryan Boreham
dc14bd04df Exit joinResults.result() if context cancelled
These can be long-running operations, and if the client retries we get
the cancelled one running in parallel with the retry, slowing both down
and making it likely the next one will time out too.
2021-04-22 10:53:06 +00:00
Bryan Boreham
947b4cc9c8 Break out of Map.Render loop if context cancelled
These can be long-running operations, and if the client retries we get
the cancelled one running in parallel with the retry, slowing both down
and making it likely the next one will time out too.
2021-04-22 09:03:05 +00:00
Bryan Boreham
5264b61951 improvement: stop rendering if Context is cancelled
Typically this means the http caller has closed the connection,
so no point responding to them.

Also check at the point we send a response back, and log to OpenTracing.
2020-06-11 11:13:38 +00:00
Bryan Boreham
c03aeb5d43 Move Counters into Latest
The only place Counters are used is in rendering, for the number of
nodes under a topology, so the overhead of holding a unique data
structure in every Node is unwarranted.

Counters are not set in the probe, so we don't need any
backwards-compatibility in report decoding. Similarly they are not set
until after all nodes are merged, so we don't need that logic.
2020-03-10 12:30:05 +00:00
Bryan Boreham
3be8cf71dd Add more Opentracing detail to the app (#3383)
* Pass Go context down to Renderers

This is useful for cancellation or tracing.

* Add tracing spans to app

Also log things like number of nodes in Map, total number of reports.
2018-10-26 11:21:33 +05:30
Bryan Boreham
cc79b7631e Propagate multiple container values at once
This is more efficient than repeatedly inserting a single value.
2018-07-18 12:52:27 +00:00
Bryan Boreham
e1c418884e Comment inconsistency between calls in joinResults 2018-04-15 09:39:43 +00:00
Bryan Boreham
3711876194 Use unsafe merge in joinResults.addChildAndChildren(), for performance 2018-04-15 09:39:21 +00:00
Bryan Boreham
b7b778934c Merge pull request #3138 from weaveworks/single-owner-nodeset
Use single-owner code path to accumulate children when rendering
2018-04-13 09:34:30 +01:00
Bryan Boreham
7a03bc03f8 Use faster code to accumulate children when rendering
Make sure all the Children NodeSets are not shared with any other
nodes, then we can use the non-persistent add path.
2018-04-13 07:44:21 +00:00
Bryan Boreham
7e63d0fd19 Comment 2018-04-10 13:25:54 +00:00
Bryan Boreham
dd087cff01 Use joinResults to accumulate nodes in Map.Render()
joinResults grew out of a special case of Map.Render(), so now we
merge the two lines back together and have just one way to accumulate
results and remap adjacencies.
2018-04-09 13:16:40 +00:00
Bryan Boreham
e3539a8d92 MapFunc is now Node->Node
Save time creating a map for the results which contains at most one entry
2018-04-09 13:16:40 +00:00
Matthias Radestock
c8ea7ba49e refactor: simplify joinResults.add*
After dropping extra metadata in the rest of this PR, our usage of
joinResults.add* only ever ends creating minimal nodes, from just an
id and topology. Hence joinResults.add* can be invoked with simply an
id and topology instead of a generic node creation function.
2017-12-29 14:40:18 +00:00
Matthias Radestock
724ea0c230 refactor: extract common code of joinResults.addChild variants 2017-12-21 10:05:56 +00:00
Matthias Radestock
7d261d0ca0 don't map image adjacencies to hosts
it's just wrong
2017-12-21 10:05:56 +00:00
Matthias Radestock
ee4a56e8ad optimse common one->one mapping case
one->many is much rarer
2017-12-19 19:34:52 +00:00
Matthias Radestock
25eeec0227 enhance joinResult to handle mapping one node to multiple nodes 2017-12-18 21:13:15 +00:00
Matthias Radestock
f920f1b9d2 refactor: extract helper to add joinResult mapping 2017-12-18 18:41:52 +00:00
Matthias Radestock
ba7af78cfa ensure result adjacencies start empty
Any existing list would be mutated by result(), which is bad.

Note that all the existing newJoinResults() call sites pass in nodes
with no adjacencies, so this is purely a safety measure.
2017-12-17 18:24:32 +00:00
Matthias Radestock
ac87c2b6e8 optimise & simplify node propagation in joinResult
Instead of copying unmatched nodes at the end, and matched nodes when
we encounter them, copy *all* nodes at the beginning.
2017-12-17 18:14:48 +00:00
Matthias Radestock
f16908aea9 refactor: fix up adjacencies as part of joinResult.result() 2017-12-17 18:14:47 +00:00
Matthias Radestock
0c894e9446 refactor: drop networks from render.MapFunc
All the MapFuncs that needed networks have been elevated to Renderers.
2017-12-17 00:18:12 +00:00
Matthias Radestock
7bbded9e84 refactor(ish): introduce Tranformers
so we can generalise the filter step in render.Render et al. That will
allow us to apply whole-topology filters in that step.
2017-11-28 06:54:15 +00:00
Matthias Radestock
be8801ab92 optimisation: faster knownServiceCache
We use an LRU cache implementation that is keyed on strings, which
avoids conversion to/from interface and the memory allocation that
entails.
2017-11-25 19:33:49 +00:00
Matthias Radestock
1c39d14c74 make render.ResetCache() reset all caches
so that benchmarks yield more consistent results.
2017-11-22 13:00:39 +00:00
Bryan Boreham
3e62f7b754 Rewrite MapProcess2Name to process all nodes in one pass
This is more efficient as there are typically many fewer names than
processes.
2017-11-22 10:33:00 +00:00
Matthias Radestock
346a0360ef Refactor: split addToResults into two functions
This is preparatory to future refactorings: all existing calls are to
Endpoints which have no children and where we don't want a Counter.

We make addChildAndChildren an obvious extension of addChild even
though it adds a dead code path (we never call addChildAndChildren
with an endpoint).
2017-11-22 10:30:18 +00:00
Matthias Radestock
0c43526465 refactor: use new FilterFunc.Apply
instead of constructing temporary Filter renderers.

This also makes clearer what is going on.
2017-11-21 20:16:59 +00:00
Matthias Radestock
88e8b52d66 Decorators, begone!
Decorators were just a complicated way of constructing filters.
2017-11-21 20:16:30 +00:00
Matthias Radestock
ae153e57f5 refactor: remove Decorator from render.Renderer.Render() signature 2017-11-18 18:04:52 +00:00
Matthias Radestock
a82d245e93 simplify render decoration
Decoration is in fact quite a simple process that is applied on entry
to rendering: we take a base renderer, transform it with a decorator,
and then render a report with it. The new render.Decorate() function
does exactly that.

There is one exception. When rendering an individual node, e.g. for
showing its details panel in the UI, we must not lose the node during
decoration. That requires some special logic, which previously resided
in the PreciousNodeRenderer, and now lives in handleNode.
2017-11-18 18:04:52 +00:00
Matthias Radestock
aaf4e54df2 pass render filters and maps by value rather than reference
They are small and don't carry mutable state, so there is no point
passing them by reference.
2017-11-18 12:10:00 +00:00
Matthias Radestock
9bd8bd825b remove now superfluous Renderer.Stats method
step 2 (and final step) in producing stats as part of Rendering
2017-11-08 07:15:28 +00:00
Matthias Radestock
8f7e00f46a Stats are easily produced as part of Rendering
...so there is no need for a separate Stats method.

step 1: return stats from Render
2017-11-08 07:15:28 +00:00
Bryan Boreham
4feb451760 Refactor join-Renderer helper functions as methods
New type joinResult is created to hold the nodes and ID mapping.
The implementation move from host.go to render.go.
2017-11-06 22:12:13 +00:00
Matthias Radestock
2bdab7513e ditch all memoisation
we will re-introduce it more selectively later
2017-11-04 22:21:50 +00:00
Matthias Radestock
86292acf47 micro refactor: save a line, narrow scope 2017-08-18 19:28:36 +01:00
Matthias Radestock
1f023890e4 refactor: optimise report.Map.Render() 2017-07-03 07:54:32 +01:00
Matthias Radestock
91d3497f7d parallelise 'reduce' 2017-06-05 08:44:17 +01:00
Filip Barl
2e9255b190 Addressed the comments and fixed the tests. 2017-02-20 11:40:40 +01:00
Alfonso Acosta
5eabf5436c Make linter happy 2016-10-05 13:07:17 +00:00
Alfonso Acosta
3f27d5f6cc Do not filter out the target nodes when obtaining the details panel 2016-10-05 12:22:50 +00:00
Tom Wilkie
57618be932 Add a condition to rendering any kubernetes nodes at all 2016-05-03 17:05:44 +01:00
Tom Wilkie
9eaac25d69 Don't merge nodes in the rendering pipeline 2016-05-03 15:18:31 +01:00
Tom Wilkie
b4a59f6e36 Don't recursively gets stats beyond an ApplyDecorators decorator 2016-04-29 12:06:33 +01:00
Paul Bellamy
3d3aed2bb3 Fixing grouped node count for filtered children nodes
Squash of:

* We have to keep all the container hostnames until the end so we can
  count how many we've filtered

* Adding tests for ContainerHostnameRenderer and PodServiceRenderer with
  filters

* Because we filter on image name we need the image name before
  filtering

* Alternative approach to passing decorators.

* Refactor out some of the decorator capture

* Don't memoise decorated calls to Render

* Fixing filtered counts on containers topology

  Tricky, because we need the filters to be silent sometimes (when they're
  in the middle), but not when they're at the top, so we take the "top"
  filter's stats. However, this means we have to compose all
  user-specified filters into a single Filter layer, so we can get all
  stats.

  There are no more Silent filters, as all filters are silent (unless they
  are at the top).

  Additionally, I clarified some of the filters as their usage/terminology
  was inconsistent and confused. Now Filter(IsFoo, ...) *keeps* only nodes
  where IsFoo is true.
2016-04-28 12:23:43 +01:00
Tom Wilkie
22e8418e7a Reorganise the render/ package 2016-04-22 11:07:07 +01:00
Paul Bellamy
2c6b6e6707 Refactoring rendering to remove RenderableNode
Squash of:
- use detailed.Summaries to render topology nodes
- ban merging nodes of different topologies (they should be mapped)
- need to prune parents when mapping node types
- render container images by id if they have no name
- remove separate render ids and prune parents in NewDerived*
- don't render metrics/metadata for groups of nodes
- fixing up tests
- removing pending unit tests (for mapping.go, for now)
- updating experimental dir for RenderableNode removal
2016-03-29 14:13:03 +01:00
Paul Bellamy
94d52f02a7 Refactored render/memoise and added a basic test for it 2016-01-27 16:29:55 +00:00