Commit Graph

265 Commits

Author SHA1 Message Date
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 Boreham
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 Lang
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
Mike Lang
fad3e88269 Rename ECS Service node ids to be cluster;serviceName
This is important for two reasons:
* It prevents nasty false-equality bugs when two different services from different ECS clusters
  are present in the same report
* It allows us to retrieve the cluster and service name - all the info we need to look up the service -
  using only the node ID. This matters, for example, when trying to handle a control request.
2017-02-03 13:45:18 -08:00
Filip Barl
d3466b5454 Refactored the table component/model and wrote the tests
Backward-compatibility fix
2017-01-16 17:05:36 +01:00
Filip Barl
e475a09ee6 Rendering sortable generic tables in the UI
Rendering generic table columns

Made Type a required attribute for TableTemplate

Made generic table sortable on the UI
2017-01-16 12:22:10 +01:00
Filip Barl
31be525bd2 Created generic table model on backend
Replaced MetadataRow with generic Row in Table model

Sending through multicolumn tables from the backend
2017-01-16 12:22:10 +01:00
Jonathan Lange
1020fc5f85 Use test.Diff from common 2016-12-07 11:22:40 +00:00
Jonathan Lange
e8085b01b6 Use 'common' library 2016-12-07 11:22:38 +00:00
Alfonso Acosta
78775bbdb8 Initial rendering for ECS
(not working yet)
2016-11-29 07:18:05 -08:00
Mike Lang
db23e64e9c Add new topologies ECSTask and ECSService 2016-11-29 07:17:16 -08:00
Alfonso Acosta
375ce6b33c Review feedback 2016-11-02 13:16:13 +00:00
Alfonso Acosta
d0e022050e Fix and extend tests 2016-11-02 13:16:12 +00:00
Alfonso Acosta
216cc0d605 Add image table to container nodes
Also, extend metadata of images with sizes
2016-11-02 13:16:11 +00:00
Alfonso Acosta
9367d95cb0 Allow providing fixed entries in tables 2016-11-02 13:00:15 +00:00
Alfonso Acosta
306ad68a81 Fix bug when parsing peer names 2016-10-26 07:47:17 +00:00
Alfonso Acosta
e80a01aab9 Filter out docker overlay peers 2016-10-24 17:37:53 +00:00
Lorenzo Manacorda
7ed139b15b fix linter errors on unkeyed fields 2016-10-14 12:53:48 +02:00
Simon Howe
3c393c7808 Move truncation of docker ids to FE to allow full value in tooltips
- Reveals full id if you search for it.
- Difficult to copy and paste the full id if you want it for some reason
2016-09-28 12:18:12 +02:00
Alfonso Acosta
c10c58459b Fix spelling mistakes 2016-08-18 17:48:45 +00:00
Krzesimir Nowak
0ecb908c22 Ensure backward compatilibity in report's node controls
The new probe will convert all node's LatestControls to Controls, so
the old app can consume them. Also, the new app will convert all
node's Controls to LatestControl, so it can consume the reports from
old probes.
2016-08-12 17:15:43 +02:00