Commit Graph
383 Commits
Author SHA1 Message Date
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 SchilterandGitHub 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
jpellizzariandMike Lang 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
Matthias Radestock 94a11ff2e8 encode empty ps.Maps as nil
every little helps
2017-05-29 17:50:55 +01:00
Matthias Radestock 29f2af11d9 introduce mapKeys helper 2017-05-29 14:08:26 +01:00
Matthias Radestock 87d91c55d9 use mapToString where possible 2017-05-29 14:08:26 +01:00
Matthias Radestock f09be95a43 use mapEqual where possible 2017-05-29 14:08:26 +01:00
Matthias Radestock fa0f4a4d59 add copyreport utility
useful for codec and report structure experiments
2017-05-26 15:33:15 +01:00
Matthias Radestock eb8695965a refactor: move report file reading 2017-05-26 15:30:17 +01:00
Mike Lang c60731b043 Add report topology for daemonsets 2017-05-19 15:00:01 -07:00
Matthias Radestock 17b88b4110 eliminate excessive calls to mtime.Now()
This isn't going to noticeably improve performance, but enables future
optimisations, e.g. more compact representations of LatestMaps where
many/all entries share the same timestamp.
2017-04-28 23:54:24 +01:00
Matthias Radestock 911f456a18 make Node.WithTableTruncationInformation private
It is not used elsewhere and is rather specialised.
2017-04-28 23:43:35 +01:00
Bryan Boreham b49ee2ae95 Remove Gob from report package - no longer used 2017-04-25 12:26:15 +00:00
Bryan Boreham 36ff5ab71a Write psMap out directly
rather than going via intermediate data structure
2017-04-25 10:38:56 +00:00
Bryan BorehamandGitHub c944225475 Merge pull request #2437 from kinvolk/alban/gzip-compression-level-default
gzip: change compression level to the default
2017-04-18 10:45:38 +01:00
Mike Lang 6bf34ab95d Add SwarmService topology containing data on Docker Swarm services 2017-04-14 12:51:28 -07:00
Mike LangandGitHub 460352d2d7 Merge pull request #2436 from weaveworks/mike/easier-added-topologies
Reduce the number of places topologies are explicitly listed
2017-04-14 12:49:12 -07:00
Alban Crequy a8af81fe20 gzip: change compression level to the default
We want the middle ground between a small compression size, a fast
compression time and a fast decompression time.

Tests suggest that the default compression level is better than the
maximum compression level: although the reports are 4% bigger and
decompress slower, they compress 33% faster.

See discussion on https://github.com/weaveworks/scope/issues/1457#issuecomment-293288682
2017-04-12 17:41:43 +02:00
Mike Lang 7ba3555fe6 report: Reintroduce explicit topology listing for Walk functions
To avoid needing to allocate a new map every time, since we're already
hitting GC-related perf issues
2017-04-10 14:30:53 -07:00
Bryan Boreham 515f4b1a47 Make various anonymous fields named
Anonymous fields make any methods on the inner object visible on the
outer, so they should only be used when the outer is-a inner.
2017-04-01 11:35:10 +00:00
Mike Lang eb0298b9d5 report: Refactor various methods to avoid explicitly listing topologies
By reducing the number of times we refer to every topology by name line by line,
we make it easier to add new topologies, reduce the risk of bugs where a topology is not listed,
and reduce the risk of the repeated lines getting out of sync with each other.

We introduce two new methods to assist this:
	WalkPairedTopologies, a modified WalkTopologies that gives the called function
		the same topology from two reports. This is used, for example, to implement Copy and Merge.
	TopologyMap, which returns a map of all topologies by name. This is then used to implement all other methods.

This leaves only 4 instances of listing topologies:
	In the consts at the top of the file, to give it a name
	In the struct itself
	In the constructor, where we need to set per-topology settings
	In TopologyMap
2017-03-30 16:38:34 -07:00
Bryan Boreham b3f53a7a81 Call CodecDecodeSelf() instead of Decode()
This avoids a runtime type lookup, so goes a little faster.
Also having less recursion makes it easier to interpret profiles.
2017-03-23 12:25:12 +00:00
Bryan Boreham 6f80fcd870 Use faster mapRead function everywhere 2017-03-23 12:25:12 +00:00
Bryan Boreham de97a72661 Remove indirection via LatestMap
Structs like StringLatestMap now use ps.Map directly, which saves
a memory allocation for LatestEntry.Value to point to.
The values in the ps.Map are now pointers, which saves a memory
allocation indirecting a value type to an interface{}
2017-03-20 11:51:04 +00:00
Bryan Boreham 970ab66ea0 Extract map helper functions 2017-03-20 11:50:19 +00:00
Bryan Boreham b085c80ef3 Decode via byte slice for memcache and file read
This is more efficient, since the decoder can read field names in-place.
It also appears to be absolutely faster.
2017-03-14 14:54:17 +00:00
Mike Lang 1dcfe58b3d Add test to check ECS Service node id parsing is back-compatible 2017-02-03 13:55:11 -08:00