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

MIDI: reading performance can be improved #1174

Closed
kwikwag opened this issue Nov 27, 2021 · 3 comments · Fixed by #1207
Closed

MIDI: reading performance can be improved #1174

kwikwag opened this issue Nov 27, 2021 · 3 comments · Fixed by #1207

Comments

@kwikwag
Copy link
Contributor

kwikwag commented Nov 27, 2021

Motivation
The code that reads in MIDIs uses a lot of inefficient code, causing in rather slow reads.

Feature summary

I tried some straightforward approaches to make it more efficient. See https://github.com/kwikwag/music21/tree/feature/midi-read-performance

Proposed implementation

  • Replace bytes with memoryview for the reading process.
  • Use a pre-calculated frozenset() for the _ContainsEnum base class

Intent

[x] I plan on implementing this myself.
[ ] I am willing to pay to have this feature added.
[x] I am starting a discussion with the hope that community members will volunteer their time to create this. I understand that individuals work on features of interest to them and that this feature may never be implemented.

@kwikwag
Copy link
Contributor Author

kwikwag commented Nov 28, 2021

Note: with this change, event.data will return a memoryview where it used to have bytes. I can change that, but not sure what would be best.

@jacobtylerwalls
Copy link
Member

Hi, thanks for using the package and thinking of giving back.

Regarding the two proposed changes, do you have a benchmark? You mention the frozenset change saves 5%. What about the other? (The other diff is much bigger, so it would help to evaluate processing time vs. patch review time / documentation time.)

Note: with this change, event.data will return a memoryview where it used to have bytes.

This sounds like something that might need to wait for v. 8. The frozenset change could go in now.

@jacobtylerwalls jacobtylerwalls linked a pull request Nov 28, 2021 that will close this issue
@kwikwag
Copy link
Contributor Author

kwikwag commented Nov 28, 2021

They both are at aboud 5% is my measurements. I will try to come up with a benchmark set. I'll fix the pylint problems first.

And thank you for the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants