Commit Graph

307 Commits

Author SHA1 Message Date
Matthias Radestock
9419c3ef5c refactor(ish): reduce number of topology lists
Having 6 lists of topolgies in the same file is a bit much:

1. consts for topology names
2. Report type definition
3. MakeReport() Report initialisation
4. Report.Topology(name) lookup
5. Report.TopologyMap() mapping of names to topology references
6. Report.WalkPairedTopologies() iterator over topology references

We get rid of 5 and 6 by introducing a topologyNames slice. So we
are down to 5.

We replace Report.TopologyMap() with a new function,
WalkNamedTopologies, that uses topologyNames. WalkPairedTopologies()
is updated to operate in a similar fashion. Likewise for
WalkTopologies() and Topologies() - these were previously calling
Walk[Paired]Topologies, but it is clearer to simply implement them
directly.
2017-12-24 22:26:57 +00:00
Matthias Radestock
583e81d733 make Report.Toplogy(name) fast
Previously this was buidling a fresh map of all topologies, just so it
could look up the one given as an argument.

Node summarisation (via detailed.Summaries) in particular was badly
affected by that.
2017-12-24 19:11:24 +00:00
Matthias Radestock
315b05062f remove vestiges of edge metadata from comments 2017-12-17 18:38:36 +00:00
Matthias Radestock
b540a1639b fix comment: overlay edges *are* present 2017-12-17 18:37:14 +00:00
Matthias Radestock
e93b69cf10 remove Node.Edges
It is unused and none of the adjacency mapping code in the renderer
takes any notice of it. Removing this shrinks the report size.

Edges were introduced in #838. At the time we had an experimental
packet sniffer under experimental/sniff/sniffer.go. That got removed
in #1646.

We can resurrect this if we ever decide to add meta data to edges.
2017-12-17 13:28:22 +00:00
Matthias Radestock
e24d3e93fe Add static map of common keys to reduce allocations 2017-12-11 20:26:47 +00:00
Matthias Radestock
1f2247a8c4 move node metadata keys into report package
Both the probe and the app (for rendering) need to know about them.
2017-12-11 20:26:08 +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
ea20de58be Merge pull request #2964 from weaveworks/do-not-reportallocs
do not report allocations in benchmarks
2017-12-08 14:11:18 +00:00
Matthias Radestock
d528292cd4 make report upgrading fast when it's a no-op
The vast majority of the cost is memory allocation, so doing a first
pass to see whether any upgrading is necessary at all, and thus
avoiding allocation when it isn't, is a massive saving.
2017-12-07 21:01:34 +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
Bryan Boreham
d1bf98dfde Remove struct wrapping LatestMap
It isn't necessary, and it prevents the codec from seeing maps as empty
2017-12-06 15:46:31 +00:00
Matthias Radestock
4162b5d734 allocate less memory in LatestMap merging
Most maps we merge have the same keys, or at least one set of keys is
the subset of the other. Therefore, allocate a result slice capable of
holding only the max of number keys, rather than the sum.
2017-12-02 13:13:08 +00:00
Matthias Radestock
c953313b01 move main report processing benchmarks in one place
so they can share code and are easier to run in combination.

We take advantage of the code sharing by generalising the report
rendering benchmarks to read & merge reports from a dir.
2017-12-02 11:29:16 +00:00
Bryan Boreham
05d5d339c4 Decode reports from a byte buffer
Reading and uncompressing the entire message into memory first allows
the decoder to avoid memory allocations in field names, etc.
2017-11-29 21:56:55 +00:00
Matthias Radestock
cdbc01ecf9 simplify report.MakeFromFile
this new version is less efficient... but not for much longer
2017-11-29 21:48:52 +00:00
Matthias Radestock
ecf3ae90ff add a benchmark for report unmarshalling 2017-11-29 21:48:52 +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
Bryan Boreham
e41332a775 In id-parsing functions, Split strings using Index to save allocations
These routines are called a lot, so this change reduces garbage collection
2017-11-15 23:15:10 +00:00
Filip Barl
e233e64279 Improved the duration parsing on frontend. 2017-11-03 10:43:41 +01:00
Filip Barl
320b9e240f Abstracted the report data types. 2017-11-03 10:43:41 +01:00
Bryan Boreham
5acece6e58 Refactor: loop replaced with append() 2017-10-11 09:50:06 +00:00
Bryan Boreham
a52c9df48c Added benchmarks for encode and decode of StringLatestMap 2017-10-01 16:19:00 +00:00
Bryan Boreham
736ae5e7c8 Refactor: extract fn to make map for benchmarks 2017-10-01 16:19:00 +00:00
Bryan Boreham
29f139d424 Re-implement LatestMap as a sorted slice for better performance
both the Python generator and the Go generated code are checked in
2017-10-01 16:18:59 +00:00
Bryan Boreham
9322b54b68 Stop causing errors by parsing empty strings as time.Time
We encode the zero time as an empty string, so we should do the
reverse when decoding.

Otherwise time.Parse() returns an error, which is created on the heap,
causing extra garbage-collection load.
2017-09-30 14:33:20 +00:00
Damien Lespiau
466927ce68 lint: Fix 2 sites failing a recently introduced golint check
golint has gained a new check and we don't freeze the golint version so CI was
failing on unrelated PRs:

app/multitenant/consul_client.go:69:2: redundant if ...; err != nil check, just return error instead.
report/marshal.go:188:2: redundant if ...; err != nil check, just return error instead.

Fix those!
2017-09-26 12:15:09 +01:00
Roland Schilter
0d381a34d6 Link scope-ui graphs clickable to prometheus queries (#2664)
scope-app:
* Adds `-app.metrics-graph` cli flag for configuring the base url to
use for graph links; supports :orgID and :query placeholders
* Assigns query URLs to existing metrics and appends empty metrics if missing

scope-ui:
* Extends <CloudFeature /> with option alwaysShow
* Adds <CloudLink /> to simplify routing when in cloud vs not in cloud
* Links metric graphs in the ui's node details view for all k8s
toplogies and containers so far
* Tracks metric graph click in mixpanel `scope.node.metric.click`
* Uses percentages and MB for CPU/Memory urls
* Passes timetravel timestamp to cortex in deeplink
2017-08-15 18:56:23 +01:00
Matthias Radestock
7db84aba21 make network calculation commutative 2017-08-10 11:08:42 +01:00
Matthias Radestock
4dae7edc9c synthesise k8s service network from service IPs
This prevents cluttering host.LocalNetworks with lots of /32
addresses. These were unsightly and rather distracting in the UI. They
also bloated the report and slowed down server-side rendering.

Fixes #2748.
2017-08-01 12:17:50 +01:00
Mike Lang
316ae2947c Fiddle with k8s topology shapes again
Final list of shapes for controllers view, with rationale:
Heptagon for Deployment - same shape as Service, which typically have a corresponding Deployment
Triangle for CronJob - weird shape for weird thing
Pentagon for DaemonSet - because pentagons and daemon worship :P
Octagon for StatefulSet - last shape left
2017-07-19 11:16:59 -07:00
Mike Lang
9fb6c46467 Add report topologies for Stateful Sets, Cron Jobs 2017-07-18 11:35:50 -07:00
Matthias Radestock
4dbb913ca2 refactor: remove dead Copy() code 2017-07-04 07:35:30 +01:00
Matthias Radestock
a6491a35c3 refactor: remove unnecessary Copy() code 2017-07-04 07:35:30 +01:00
Matthias Radestock
cfbbdf7bf0 refactor: optimise report.Sets.Delete() going empty
Mainly for consistencty; we do something similar NodeSet.Delete().
2017-07-03 03:19:52 +01:00
Matthias Radestock
430e74a80a refactor: remove report latest map Delete()
It wasn't used, and is problematic in any case since it introduces
non-monotonicity.
2017-07-03 02:06:21 +01:00
Matthias Radestock
5b131b1ea6 refactor: remove a couple of report set Remove() functions
They were unused and their naming was inconsistent with similar
operations (that are called Delete()).
2017-07-03 01:26:22 +01:00
Matthias Radestock
7119fb9de8 refactor: rename report.NewNetworks to MakeNetworks
for consistency - all the other report set constructors are called
'Make...'
2017-07-03 01:26:22 +01:00
Matthias Radestock
fd3fc6656d refactor: add some more empty report set objects
for efficiency and consistency
2017-07-03 01:26:22 +01:00
Matthias Radestock
b5f3aa68ae refactor: optimise "empty" case in report set constructors 2017-07-03 01:26:22 +01:00
Matthias Radestock
9dc50b5202 refactor: hide "empty set" constants
They are an implementation detail.
2017-07-03 01:26:22 +01:00
jpellizzari
4f341cb1d2 Add new node shapes for k8s combined view
While we're there, adopt a consistent ordering for all places that shapes are listed
Order is least sides to most sides, with circle before polygons, and complex shapes (currently just Cloud) after.

On shape choices for topologies:
* Since the k8s logo is a heptagon, we want pods to be heptagons.
* Since triangle is 'a bit weird', we put it on the least-important type, replica sets.
* Pentagons look a little weirder than octogons (it's the lack of symmetry) so we put octogons on the most common (deployments)
2017-06-27 10:19:04 -07:00
Matthias Radestock
a306867610 fast network membership check
The rendering code checks whether endpoint IPs are part of
cluster-local networks. Due to the prevalence of endpoints - medium
sized reports can contain many thousands of endpoints - this is
performance critical. Alas the existing code performs the check via a
linear scan of a list of networks. That is slow when there are more
than a few, which will be the case in the context of k8s, since there
the probes register service IPs as local /32 networks.

Here we change representation of the set of networks to a prefix
tree (aka trie), which is well-suited for IP network membership checks
since networks are in fact a bitstring prefixes.

The specific representation is a crit-bit tree, but that choice was
purely based on implementation convenience - the chosen library is the
only one I could find that directly supports IP networks.
2017-06-21 03:03:49 +01:00
Matthias Radestock
9e75331e9a Revert "fast network membership check"
This reverts commit 98f036359b.
2017-06-20 20:51:27 +01:00
Matthias Radestock
98f036359b fast network membership check
The rendering code checks whether endpoint IPs are part of
cluster-local networks. Due to the prevalence of endpoints - medium
sized reports can contain many thousands of endpoints - this is
performance critical. Alas the existing code performs the check via a
linear scan of a list of networks. That is slow when there are more
than a few. Unfortunately in some common k8s network setups, e.g. on
AWS, a cluster can contain hundreds of networks, due to /32 networks
derived from interfaces with multiple IPs.

Here we change representation of the set of networks to a prefix
tree (aka trie), which is well-suited for IP network membership checks
since networks are in fact a bitstring prefixes.

The specific representation is a crit-bit tree, but that choice was
purely based on implementation convenience - the chosen library is the
only one I could find that directly supports IP networks.
2017-06-20 19:31:11 +01:00
Matthias Radestock
1ef56f6af6 refactor: extract common code 2017-06-20 12:03:02 +01:00
Matthias Radestock
7e5704b53b fix tests
...by removing them. It was a ridiculous amount of contorted code to
test some utterly trivial functionality that is largely provided by
the golang stdlib.
2017-06-20 12:03:02 +01:00
Matthias Radestock
4e0065a57d refactor: put all network detection code in one place 2017-06-20 09:23:52 +01:00
Matthias Radestock
19a6551de2 ignore local IPv6 addresses/networks
There is no point in paying attention to them since scope connection
tracking only deals in IPv4.
2017-06-20 09:04:08 +01:00
Matthias Radestock
6679c42c0e optimise: don't sort in NodeSet.ForEach
It's unnecessary, and none of the other ps.Map derived structures do
it.
2017-05-30 13:42:18 +01:00