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

Optimize Rectangle class memory management and performance, file: vertex_instructions.pyx (part of the issue #8664) [WIP] #8726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tuliogv
Copy link

@tuliogv tuliogv commented May 13, 2024

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: xxx label.
  • Applied the api-deprecation or api-break label.
  • Applied the release-highlight label to be highlighted in release notes.
  • Added to the milestone version it was merged into.
  • Unittests are included in PR.
  • Properly documented, including versionadded, versionchanged as needed.

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.
Copy link

welcome bot commented May 13, 2024

Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines.

@tuliogv
Copy link
Author

tuliogv commented May 13, 2024

I tested results runining 100 instances of 10000 rectangues creations several times, and it gets an average of 5% improvements.

before:
testeOrig

after:
TesteMod

@misl6
Copy link
Member

misl6 commented May 22, 2024

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)

@tuliogv
Copy link
Author

tuliogv commented May 22, 2024

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

@misl6
Copy link
Member

misl6 commented May 22, 2024

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)

@tuliogv tuliogv changed the title Optimize Rectangle class memory management and performance, file: vertex_instructions.pyx (part of the issue #8664) Optimize Rectangle class memory management and performance, file: vertex_instructions.pyx (part of the issue #8664) [WIP] May 26, 2024
@tuliogv
Copy link
Author

tuliogv commented May 27, 2024

I'm still working on the changes and i'm also trying to test every thing properly, this is going to take a while...

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

2 participants