Commit Graph

551 Commits

Author SHA1 Message Date
Matthias Radestock
f16908aea9 refactor: fix up adjacencies as part of joinResult.result() 2017-12-17 18:14:47 +00:00
Matthias Radestock
e5117a652f remove superfluous fixupAdjacencies calls
fixupAdjacencies fixes up adjancencies of mapped nodes. The nodes at
the call sites we are removing aren't mapped.
2017-12-17 18:14:30 +00:00
Matthias Radestock
cc859926ef tiny simplifying refactor 2017-12-17 15:36:28 +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
20138b9218 don't exclude NATed connections in mapping to processes
We used to ignore source endpoints that are associated with multiple
destination endpoints, which is a partial workaround for our inability
to correctly represent two connections from the same source ip/port
but different processes, or the same destination ip/port but different
processes. See #2665.

However, that condition is too coarse. In particular, we end up
ignoring endpoints that are connected to NATed destinations, since the
latter are represented by two (or more) endpoints.

The change here corrects that.
2017-12-15 11:40:43 +00:00
Roberto Bruggemann
c08d39f8bd report.Upgrade() add deployments to pods as parent
This was previously done selectPodsWithDeployments.Render().
2017-12-11 14:50:41 +00:00
Matthias Radestock
1865c46368 refactor: introduce a constant for "copy_of"
since it's shared between the probe and renderer
2017-12-09 10:45:59 +00:00
Matthias Radestock
f305c35bfd do not report allocations in benchmarks
That's what -benchmem is for.
2017-12-07 20:27:31 +00:00
Matthias Radestock
9fbc388f82 filter internet adjacencies
Edges between the incoming and outgoing internet nodes are typically
artifacts of imperfect connection tracking, e.g. when VIPs and NAT
traversal are in use.

So lets filter them out.
2017-11-28 13:23:17 +00:00
Matthias Radestock
956303694a always apply ColorConnected in process renderers
This eliminates the awkward distinction between ProcessRenderer and
ColorConnectedProcessRenderer.

It also ensures that processes resulting from direct rendering of the
process topology (/api/topology/processes is invoking
ProcessWithContainerNameRenderer and /api/topology/processes-by-name
is invoking ProcessNameRenderer) are colored and hence summarising
them correctly sets the 'linkable' property. This was the behaviour
prior to the revamping of the rendering pipeline. However, it doesn't
actually make a practical difference since process detail panels only
show other processes as connection endpoints, and these are always
marked linkable anyway.
2017-11-28 06:54:15 +00:00
Matthias Radestock
f193a2101c refactor: remove duplication of filtering logic 2017-11-28 06:54:15 +00:00
Matthias Radestock
1416fe928f remove filtering of unconnected pseudo nodes from ordinary filters
It's now done via a special filter, once, after all other filters have
been applied.

Some tests need updating since they were relying on ordinary filters
doing that filtering.
2017-11-28 06:54:15 +00:00
Matthias Radestock
9dca7627b6 filter unconnected nodes after applying user-specified filters
...rather than before. That way, nodes which become unconnected during
filtering are removed, which is what we want. ATM we are depending on
some 'unconnected' filtering inside every filter, which is expensive
and largely redundant. We should soon be able to remove that.

downside: 'unconnected' filtering is no longer memoised.
2017-11-28 06:54:15 +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
97fadd6d9f optimising refactor: FilterUnconnected{Pseudo} w/o LatestMap
Instead of three passes
1. building a 'connected' node set
2. marking nodes from that set with a LatestMap entry
3. removing unmarked nodes

we just do two
1. building a 'connected' node set
2. removing nodes not in that set

This does entail duplication of the adjecency list pruning code from
FilterFunc.Apply. We will be able to eliminate that eventually, but
not just yet.

Also, we cannot get rid of ColorConnected completely;
ColorConnectedProcessRenderer uses it to mark nodes, and that
information is required by detailed.processNodeSummary to determine
whether a process in the details panel can be rendered as a link.
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
5bdf46956d optimisation: make Memoise(Memoise(...)) only memoise once
All outputs of Memoise() are fixpoints to the function, i.e. feeding
them as inputs to the function just returns them.

We don't hit this optimisation in current code but have had instances
in the past.
2017-11-23 17:03:33 +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
Matthias Radestock
1c206fb1c9 cosmetic: bring comment up to date 2017-11-22 10:40:34 +00:00
Bryan Boreham
5697d53034 Rewrite MapX2Host as a RenderFunc using joinResults
It's more efficient as many input Nodes map onto a few hosts.
2017-11-22 10:39:37 +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
f56a44e67d cosmetic: move a function 2017-11-22 09:46:33 +00:00
Matthias Radestock
334dba20e7 cosmetic: move some functions 2017-11-22 09:19:10 +00:00
Matthias Radestock
b24334c246 fix small bug in Filtered calculation
Filtering nodes *adds* to the Filtered count.
2017-11-22 09:13:23 +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
e643ec56be refactor: move filter logic to FilterFunc
so it becomes accessible w/o having to construct a Filter renderer.
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
093857f37f refactor: extract a little test helper 2017-11-21 20:13:14 +00:00
Matthias Radestock
67950985ef refactor: introduce IsConnected FilterFunc
and rename existing IsConnected const to IsConnectedMark
2017-11-20 09:28:56 +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
Bryan Boreham
b9890064c2 Copy net.ParseIP and modify to save memory allocations
Pass in a slice on the stack instead of allocating one on the heap:
reduces garbage, hence makes the program run faster

Also apply knowledge that critbitgo will do an append() with one extra
byte, so we do that allocation up-front too.  This is innocuous should
we stop using critbitgo or should its internals change.
2017-11-15 23:15:55 +00:00
Matthias Radestock
21a91fe9dd remove HostRenderer memoisation
since it was only introduced to because producing stats would hit the
renderer twice, which is no longer the case.
2017-11-08 07:15:28 +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
917ef980a4 Memoise HostRenderer
This shows a big improvement in BenchmarkTopologyList
2017-11-07 10:18:27 +00:00
Bryan Boreham
ec0689b5aa Code review: improve consistency of naming and ordering 2017-11-06 22:12:13 +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
Bryan Boreham
cbba3c0fd3 Clarify use of 'id' in addToResults
Pass 'id' through to the create function and expect that the result Node has that ID.
Extract a function newPseudoNode for common calls.
2017-11-06 22:12:13 +00:00
Bryan Boreham
322aa76e02 Remove functions which are no longer called 2017-11-06 22:12:10 +00:00
Bryan Boreham
cbcb5f19fc Rewrite ProcessRenderer/MapEndpoint2Process as a single Renderer
This is much more efficient as we skip creating then merging all intermediate Nodes
2017-11-06 22:06:29 +00:00
Bryan Boreham
77a8cac65a Use helper to add result nodes in endpoints2Hosts.Render
This means we are no longer generating a Counter for the number of
endpoint sub-nodes, but it seems that data was not used.
2017-11-06 22:05:05 +00:00
Bryan Boreham
e16aaf6c43 Merge nodeToIP, endpoints2Nodes and ipToNode into one Renderer
This is much more efficient as we skip creating then merging all intermediate Nodes
2017-11-06 22:05:05 +00:00
Bryan Boreham
b684e3c6fc Rewrite MapEndpoint2Host as a Renderer
This allows us to avoid creating a host of 'IP' type Nodes then
discarding them after matching; instead we match directly and create
just the result we want.
2017-11-06 22:05:05 +00:00
Bryan Boreham
1b3e40ccb5 Refactor: extract pseudoNodeID function 2017-11-06 22:04:59 +00:00
Bryan Boreham
d230846b95 Refactor: extract externalNodeID function 2017-11-06 20:55:57 +00:00
Filip Barl
119bbab4fe Merge pull request #2915 from weaveworks/2875-humanize-durations
Humanize reported durations
2017-11-06 14:11:45 +01:00
Matthias Radestock
b3669bee84 Merge pull request #2924 from weaveworks/2923-memoise-less
remove unused memoisation

Fixes #2923
2017-11-06 10:35:22 +00:00