Optimize Rectangle class memory management and performance, file: vertex_instructions.pyx (part of the issue #8664) [WIP]
This commit overhauls the Rectangle class by implementing direct memory management in C. Changes include:
- Direct allocation and deallocation of vertex memory using malloc and free, respectively, to minimize Python's overhead.
- Update vertices directly using pointer arithmetic, enhancing the update operations efficiency.
- Integrated these changes into the property setters for and , ensuring immediate updates on vertex data without intermediary Python object manipulation.
These improvements lead to a more efficient use of memory and a performance increase of approximately 5% in rendering operations, which is particularly beneficial for applications requiring dynamic graphic updates.
Maintainer merge checklist
- [ ] Title is descriptive/clear for inclusion in release notes.
- [ ] Applied a
Component: xxxlabel. - [ ] Applied the
api-deprecationorapi-breaklabel. - [ ] Applied the
release-highlightlabel to be highlighted in release notes. - [ ] Added to the milestone version it was merged into.
- [ ] Unittests are included in PR.
- [ ] Properly documented, including
versionadded,versionchangedas needed.
Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines.
I tested results runining 100 instances of 10000 rectangues creations several times, and it gets an average of 5% improvements.
before:
after:
Hi @tuliogv,
From a first glance seems something is missing there.
Is some commit missing, or you're still working on it? (If it's the latter one, please mark it as WIP via [WIP] in PR name)
Thank you for checking on the pull request. I am indeed still working on it, specifically on refactoring the classes. My intention is not to rush through this process as others might also be working on related issues. To coordinate our efforts effectively, I've suggested that we mark the classes each one of us is refactoring. This way, we can test each one thoroughly. Once all the classes are refactored, we could proceed with a general merge. However, if there are no other contributors currently working on this, I can complete the refactoring of all the classes and update the PR accordingly. Please let me know how you would like to proceed!
Best regards, Tulio
As per today, no contributors are working on vertex instructions refactoring.
So, feel free to make all the appropriate changes (but remind to add [WIP] in the PR title, and remove it when is ready for a review)
I'm still working on the changes and i'm also trying to test every thing properly, this is going to take a while...