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

Small optimisations to PYON encoding #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SquidDev
Copy link

We've been seeing a couple of performance issues when serialising large PYON files1. This PR makes a couple of changes to the PYON encoder to improve performance without changing behaviour:

  • Use json.dumps to quote strings, rather than str.translate, which is significantly faster. This does mean that unicode characters are encoded as escape sequences instead, but they should serialise the same.
  • Build up a list of strings which are concatenated at the end, rather than concatenating as we go along. This avoids the quadratic complexity of string concatenation.

Here is a quick summary of the time taken to serialise a 1.7GiB PYON object across the commits in this PR:

Commit Time (s)
c0a7ed3 97.9
0313881 14.3
be74f9f 7.7

Footnotes

  1. Most notably within the ARTIQ dashboard's StateManager, where serialising the dashboard state can cause the UI to hang for several seconds.

This is significantly faster than using str.translate.
This avoids the quadratic behaviour of string concatenation, by only
performing it at the end.
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.

None yet

1 participant