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

Use a faster JSON library #6143

Merged
merged 2 commits into from
Mar 25, 2020
Merged

Use a faster JSON library #6143

merged 2 commits into from
Mar 25, 2020

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Mar 25, 2020

Motivation

We parse JSON from multiple endpoints, with each payload being many MiB in size. Some users in resource constrained environments are experiencing abnormally high CPU usage. A more efficient parser should ameliorate that.

Additional Notes

orjson is currently the fastest JSON library available for Python, while also being the least resource-intensive (especially regarding memory). It achieves this by virtue of being a light wrapper around Rust's https://serde.rs

Other Python projects are beginning to recommend and use it too

See: https://github.com/ijl/orjson#performance

@codecov
Copy link

codecov bot commented Mar 25, 2020

Codecov Report

Merging #6143 into master will decrease coverage by 0.76%.
The diff coverage is 54.54%.

Impacted Files Coverage Δ
...ks_base/datadog_checks/base/utils/serialization.py 0.00% <0.00%> (ø)
twistlock/datadog_checks/twistlock/twistlock.py 74.12% <100.00%> (+0.11%) ⬆️
twistlock/tests/test_twistlock.py 98.24% <100.00%> (-1.76%) ⬇️
datadog_checks_dev/tests/test_docker.py 48.14% <0.00%> (-51.86%) ⬇️
datadog_checks_dev/tests/tooling/test_utils.py 73.40% <0.00%> (-26.60%) ⬇️
datadog_checks_dev/datadog_checks/dev/env.py 22.72% <0.00%> (-20.46%) ⬇️
datadog_checks_dev/datadog_checks/dev/docker.py 24.57% <0.00%> (-19.50%) ⬇️
...atadog_checks_dev/datadog_checks/dev/structures.py 68.85% <0.00%> (-18.04%) ⬇️
datadog_checks_dev/tests/test_conditions.py 82.25% <0.00%> (-17.75%) ⬇️
datadog_checks_dev/datadog_checks/dev/_env.py 54.79% <0.00%> (-9.59%) ⬇️
... and 366 more

Copy link
Contributor

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

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

Great idea, I've heard good things about orjson too, and I agree adoption is growing (eg see FastAPI).

Quick idea for converting this to a base import for frictionless usage in other integrations…

twistlock/datadog_checks/twistlock/twistlock.py Outdated Show resolved Hide resolved
Copy link
Contributor

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

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

Nice stuff!

@ofek ofek merged commit 8d6d64f into master Mar 25, 2020
@ofek ofek deleted the ofek/json branch March 25, 2020 16:28
@ofek ofek mentioned this pull request Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants