[issue37587] JSON loads performance improvement for long strings
Marco Paolini
report at bugs.python.org
Thu Aug 15 16:15:09 EDT 2019
Marco Paolini <markopaolini at gmail.com> added the comment:
I also confirm Inada's patch further improves performance!
All my previous benchmarks were done with gcc and PGO optimizations performed only with test_json task... maybe this explains the weird results?
I tested the performance of new master 69f37bcb28d7cd78255828029f895958b5baf6ff with *all* PGO task reverting my original patch:
iff --git a/Modules/_json.c b/Modules/_json.c
index 112903ea57..9b63167276 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -442,7 +442,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
if (d == '"' || d == '\\') {
break;
}
- if (d <= 0x1f && strict) {
+ if (strict && d <= 0x1f) {
raise_errmsg("Invalid control character at", pystr, next);
goto bail;
}
... and surprise...
Mean +- std dev: [69f37bcb28d7cd78255828029f895958b5baf6ff] 5.29 us +- 0.07 us -> [69f37bcb28d7cd78255828029f895958b5baf6ff-patched] 5.11 us +- 0.03 us: 1.04x faster (-4%)
should we revert my original patch entirely now? Or am I missing something?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37587>
_______________________________________
More information about the Python-bugs-list
mailing list