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

worker: use pickle instead of pyon for ipc #1675

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

charlesbaynham
Copy link
Contributor

ARTIQ Pull Request

Description of Changes

Change the ipc serialization format for worker comms to pickle instead of pyon.

This PR is not complete: see #1674 for details.

Related Issue

Type of Changes

Type
✨ New feature

All Pull Requests

  • Use correct spelling and grammar.
  • Update RELEASE_NOTES.rst if there are noteworthy changes, especially if there are changes to existing APIs.
  • Close/update issues.
  • Check the copyright situation of your changes and sign off your patches (git commit --signoff, see copyright).

Code Changes

  • Run flake8 to check code style (follow PEP-8 style). flake8 has issues with parsing Migen/gateware code, ignore as necessary.
  • Test your changes or have someone test them. Mention what was tested and how.
  • Add and check docstrings and comments
  • Check, test, and update the unittests in /artiq/test/ or gateware simulations in /artiq/gateware/test

Documentation Changes

  • Check, test, and update the documentation in doc/. Build documentation (cd doc/manual/; make html) to ensure no errors.

Git Logistics

  • Split your contribution into logically separate changes (git rebase --interactive). Merge/squash/fixup commits that just fix or amend previous commits. Remove unintended changes & cleanup. See tutorial.
  • Write short & meaningful commit messages. Review each commit for messages (git show). Format:
    topic: description. < 50 characters total.
    
    Longer description. < 70 characters per line
    

Licensing

See copyright & licensing for more info.
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.

@sbourdeauducq
Copy link
Member

sbourdeauducq commented May 10, 2021

Change the ipc serialization format for worker comms to pickle instead of pyon.

Pickle was slower than pyon when I checked (many years ago), I guess this has improved now...

@charlesbaynham
Copy link
Contributor Author

I think the more recent python stdlib include c binding by default, whereas you used to have to opt-in. That's a good point though: I ran these tests on python 3.9, I should try them on 3.6 as well.


# Write the size of the data, delimited by \n. Then, write the data
# itself. This might contain \n chars, but the receiving reader knows
# how many bytes it's expecting so it doesn't need delimiters
Copy link
Member

Choose a reason for hiding this comment

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

Why not move everything to a binary protocol with length (with struct.pack)+binary data and no special meaning for \n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could do, but the length needs delimiting in some way and newline delimiting is already implemented and well tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The loading of the binary data does completely ignore \n, it's only relevant for the length data.

Copy link
Member

Choose a reason for hiding this comment

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

the length needs delimiting in some way

Just make it a 32-bit integer (fixed four bytes). Are you planning to send messages larger than 4GB?

Copy link
Contributor Author

@charlesbaynham charlesbaynham May 11, 2021

Choose a reason for hiding this comment

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

True. For Dask, again, it's not so simple: messages can come in arbitrary numbers of frames, so I've tweaked the header to be "<size of header>,<size of chunk1>,<size of chunk2>" etc. It probably could be made fully binary if we wanted, but it's not at all performance-critical and this is a pretty easy way of doing it.

@charlesbaynham
Copy link
Contributor Author

  • Need to add Dask and mempack to requirements

@stevefan1999
Copy link
Contributor

instead of pickle, why won't we even consider msgpack, cbor or even json? these are stable format and we could use them to leverage serde in our firmware.

@sbourdeauducq
Copy link
Member

@stevefan1999 please read the prior discussion ("see #1674 for details") before commenting. There are also no plans to use serde in the firmware for performance reasons, and the protocol is simple enough not to require serialization libs anyway.

@sbourdeauducq
Copy link
Member

"""
Record known compressors

Includes utilities for determining whether or not to compress
Copy link
Member

Choose a reason for hiding this comment

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

Sounds weird to compress data for inter-process communication. IPC is not supposed to be slow and compressing data to work around IPC slowness sounds like a band-aid.

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.

3 participants