8000 performance: send active controls as a single string per node by bboreham · Pull Request #3714 · weaveworks/scope · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

performance: send active controls as a single string per node #3714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 23, 2020

Conversation

bboreham
Copy link
Collaborator

Scope "controls" are buttons to do something like restart a container.
These controls can be turned on and off by the probe, e.g. depending on whether the container is running.

Previously this information was conveyed by a complicated data structure mapping each control name to a Dead boolean which had a last-modified timestamp. All of which takes effort to send and merge.
This PR changes the representation to a single string saying which controls are active, e.g. "pause;restart;stop". String values have a timestamp, so the latest value prevails in a merge.

I guess we have to update the plugins docs but haven't really looked.

This is a protocol change, requires a version bump.

Instead of a whole extra data structure which is quite expensive to
marshal and unmarshal, just send the information in a string.  No
clever merging strategy is required - the states are all set in one
place per node type.
@bboreham bboreham marked this pull request as ready for review November 26, 2019 11:31
@bboreham bboreham force-pushed the simplify-control-serialisation branch from e4660b0 to 635cea0 Compare November 26, 2019 11:35
report/node.go Outdated
n.LatestControls = n.LatestControls.Set(control, ts, data)
return n
// ActiveControls returns a string slice with the names of active controls.
func (n Node) ActiveControls(cs ...string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cs doesn't seem to be used in the function or am I missing something? Weird how linter didn't complain:

Suggested change
func (n Node) ActiveControls(cs ...string) []string {
func (n Node) ActiveControls() []string {

10000
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it was bad copy/paste from the method above, thanks.
Go doesn't complain about unused parameters inside the function because they may be needed to conform to an interface. And it's ok to supply an empty list when calling a ... function.

if !v.Value.Dead {
cs = append(cs, name)
// Pull out the newest timestamp to use for the whole set
if ts.Before(v.Timestamp) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always true before ts is set? Because otherwise we should make sure it doesn't end up being nil I guess?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts is initialized to the "zero value" for time.Time which compares as before any real time.
ts cannot be nil as it is a value not a pointer type.

"docker_remove_container": {
"timestamp": "2019-10-14T14:36:01Z",
"value": {"dead": false}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a couple more entries here? e.g. some with the same control name but different timestamps and some with differing control names for a more complete test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a little bit more but not sure if I understand you.

Copy link
Contributor
@fbarl fbarl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR with clean code and well split commits :)

Most of my comments were minor but at least one of them points to a probably relevant typo.

Cool that you added that test - did you also do some manual testing with older reports?

Fix a logic error in ECS scale-down button, bad copy/paste in
ActiveControls() and neaten the switch cases in container controls.

Co-Authored-By: Filip Barl <filip@weave.works>
@bboreham bboreham force-pushed the simplify-control-serialisation branch from d16610e to 1dcdfab Compare January 13, 2020 15:54
@bboreham bboreham merged commit a375a54 into master Jan 23, 2020
@bboreham bboreham deleted the simplify-control-serialisation branch January 23, 2020 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0