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

Optimalization: Remove copy of RelVoid maps and reserve some vectors #1301

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

Conversation

barvirm
Copy link

@barvirm barvirm commented Mar 1, 2025

Hello I notice that every call of getMesh(...) creates local copy of auto relVoids = _geometryLoader.GetRelVoids(); I change that to reference and remove const qualifiers due to it.

My large test model shows 50% speed improvements due to this change. I didn't notice any visual changes.

Also I change package.json it was trying copy non-existing files.

@beachtom
Copy link
Collaborator

beachtom commented Mar 1, 2025

@barvirm thanks. Unless I am missing something, it was already returning a reference? The only change I can see for that is removing the const?

@barvirm
Copy link
Author

barvirm commented Mar 1, 2025

I was profiling it. I assume that if you return a reference with const qualifier in const object and on the caller site you don't have & it will create copy. Because if you try to add & on the caller side it will produce compiler error.

@beachtom
Copy link
Collaborator

beachtom commented Mar 1, 2025

My understanding is that it does not - at least not in normal C++, unless the WASM is doing something wierd. Is it the removal of the const - or the reservations that is giving you your performance improvement?

@barvirm
Copy link
Author

barvirm commented Mar 1, 2025

I was checking it even in web-ifc-test.cpp. Almost 99.99% of performance is from const removal and adding reference to the type signature on caller site.

@beachtom
Copy link
Collaborator

beachtom commented Mar 1, 2025

Ok - thanks - let me look into this a little before merging

@barvirm
Copy link
Author

barvirm commented Mar 1, 2025

After signature change and adding & to the caller side (I'm not sure if it's necessary to add &) it stops creating copy of that map on every call of that function.

@barvirm
Copy link
Author

barvirm commented Mar 1, 2025

Let me know what is causing the copy if you found out.

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.

2 participants