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

CommandQueueMT: Pre-allocate memory to avoid a bunch of allocations at startup #91727

Merged
merged 1 commit into from
May 10, 2024

Conversation

RandomShaper
Copy link
Member

There was an unused DEFAULT_COMMAND_MEM_SIZE_KB constant. I've not been able to find if it had ever been used. However, it's not a bad idea to preallocate a bit of memory so the first bunch of commands added to the queue don't cause reallocations. Not a big deal, but very easy to prevent.

I've lowered the pre-allocation size constant from 256 KiB to 64 KiB to be a bit more conservative. A lot of commands already fit there and exponential growth will take care of further needs just fine.

Made on top of #91725 because of the conflicts.

@RandomShaper RandomShaper added this to the 4.3 milestone May 8, 2024
@RandomShaper RandomShaper requested a review from a team as a code owner May 8, 2024 17:23
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks good. Can be rebased.

@akien-mga akien-mga merged commit e6780b5 into godotengine:master May 10, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@RandomShaper RandomShaper deleted the cmd_queue_prealloc branch May 10, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants