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

Session.msg_id optimization #493

Merged
merged 1 commit into from
Nov 5, 2019

Conversation

tomoboy
Copy link
Contributor

@tomoboy tomoboy commented Oct 20, 2019

I was benchmarking the ipyparallel code and discovered that the scripts where spending a lot of time acquiring msg_ids.
The msg_id property of the Session class takes a while to run just to get a unique ID.

To optimise this I changed the msg_id property function to use a message counter and to just return the session_id + message count. This also return a unique ID and runs much faster.

Using timeit to compare the existing code with my implementation I got these runtimes for 1000 000 calls to session.msg_id:

function Runtime in seconds
Existing msg_id 3.2
Reimplemented msg_id 0.86

use session_id and message counter.
This gives a unique id but uses much less time
@minrk
Copy link
Member

minrk commented Nov 5, 2019

Great!

@minrk minrk changed the title Sessiong.msg_id optimization Session.msg_id optimization Nov 5, 2019
@minrk minrk merged commit 650fd75 into jupyter:master Nov 5, 2019
@meeseeksmachine
Copy link

This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/jupyter-client-6-0-0/3414/1

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