Skip to content

Speed up SanitizingJSONEncoder on large objects w/ tests#149

Merged
kattrali merged 10 commits into
masterfrom
martin308/jonls-speed-up-sanitize
Apr 6, 2018
Merged

Speed up SanitizingJSONEncoder on large objects w/ tests#149
kattrali merged 10 commits into
masterfrom
martin308/jonls-speed-up-sanitize

Conversation

@martin308
Copy link
Copy Markdown
Contributor

Built on the great work of @jonls.

This adds some tests and makes sure that the methods are backwards compatible.

jonls and others added 7 commits April 3, 2018 11:24
Fixes an issue where trying to attach a large payload to a
notification would take a long time. Changes the
SanitizingJSONEncoder to use set instead of list for faster lookup
of ignored objects.
This tests that we are able to encode objects in a speedy manner
@martin308 martin308 requested a review from a team April 5, 2018 22:45
kattrali
kattrali previously approved these changes Apr 5, 2018
Copy link
Copy Markdown
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

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

Looks good, I'd make on tweak to the perf test for easier debugging:

Comment thread tests/test_utils.py Outdated
# json encoding is very slow on python 2.6 so we need to increase
# the allowable time when running on it
maximum_time = 18
self.assertTrue(time < maximum_time)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd alter the error message to print the values here:

- self.assertTrue(time < maximum_time)
+ self.assertTrue(time < maximum_time,
+                 "Encoding required {}s (expected {}s)".format(
+                     time, maximum_time
+                 ))

Comment thread tests/test_utils.py
# json encoding is very slow on python 2.6 so we need to increase
# the allowable time when running on it
maximum_time = 18
self.assertTrue(time < maximum_time,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like this as a pass/fail metric for tests, as it's too dependent on the performance of the CI tools.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Its dependent on the tools, but also a small canary if something goes terribly wrong under the lax requirements of this test. I'd prefer that we have something for now and look into something more thorough in the future, like a formal perf suite.

@kattrali kattrali merged commit da4ffd9 into master Apr 6, 2018
@kattrali kattrali deleted the martin308/jonls-speed-up-sanitize branch April 6, 2018 22:49
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.

4 participants