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 allocation of spvtools::opt::Instruction::operands_ #5024

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

jeremyg-lunarg
Copy link
Contributor

Reserve space for the entire operand list rather than adding them one a time.

Reserve space for the entire operand list rather than adding them
one a time.
Copy link
Collaborator

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

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

thanks!

@@ -73,6 +73,7 @@ Instruction::Instruction(IRContext* c, const spv_parsed_instruction_t& inst,
unique_id_(c->TakeNextUniqueId()),
dbg_line_insts_(std::move(dbg_line)),
dbg_scope_(kNoDebugScope, kNoInlinedAt) {
operands_.reserve(inst.num_operands);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for this optimization!
We were rather lazy in the early days.

Other ideas for future: using a utils::SmallVector instead. But picking a good default size takes care. Also, it currently lacks a reserve method.

@dneto0 dneto0 merged commit 025ea89 into KhronosGroup:master Dec 19, 2022
@jeremyg-lunarg jeremyg-lunarg deleted the jeremyg-inst-ctor-alloc branch January 23, 2023 21:42
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