Skip to content
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

Msgpack perf: write psMap out directly #2466

Merged
merged 4 commits into from
Apr 25, 2017
Merged

Msgpack perf: write psMap out directly #2466

merged 4 commits into from
Apr 25, 2017

Conversation

bboreham
Copy link
Collaborator

@bboreham bboreham commented Apr 25, 2017

There is a big performance improvement from sending the data directly rather than creating an intermediate data structure.

Before:

vagrant-ubuntu-wily-64:~/.../weaveworks/scope/report$ go test -cpu=1 -run=EncodeSpeed
ok  	github.com/weaveworks/scope/report	3.978s
ok  	github.com/weaveworks/scope/report	4.035s
ok  	github.com/weaveworks/scope/report	3.945s
ok  	github.com/weaveworks/scope/report	4.184s

After:

ok  	github.com/weaveworks/scope/report	1.951s
ok  	github.com/weaveworks/scope/report	1.934s
ok  	github.com/weaveworks/scope/report	1.971s
ok  	github.com/weaveworks/scope/report	1.970s

1.934/3.945=49%

Test program:

func TestEncodeSpeed(t *testing.T) {
	b, _ := ioutil.ReadFile("fixed.msgpack")
	r := Report{}
	d := codec.NewDecoderBytes(b, &codec.MsgpackHandle{})
	d.Decode(&r)
	for i := 0; i < 100; i++ {
		buf := &bytes.Buffer{}
		codec.NewEncoder(buf, &codec.MsgpackHandle{}).Encode(&r)
	}
}

@bboreham
Copy link
Collaborator Author

Note that some toIntermediate functions remain, because they are called by Gob code. Is Gob used anywhere in Scope nowadays?

rather than going via intermediate data structure
@bboreham bboreham force-pushed the map-write-optimise branch from 9d4151d to 36ff5ab Compare April 25, 2017 10:45
@2opremio
Copy link
Contributor

Note that some toIntermediate functions remain, because they are called by Gob code. Is Gob used anywhere in Scope nowadays?

No, please ditch them (#971)

@bboreham
Copy link
Collaborator Author

gob ditched

@bboreham bboreham merged commit 8ad2d0e into master Apr 25, 2017
@dlespiau dlespiau deleted the map-write-optimise branch November 2, 2017 12:29
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