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

Audit use of const& in interfaces #874

Open
lifflander opened this issue Jun 21, 2020 · 3 comments · May be fixed by #1875
Open

Audit use of const& in interfaces #874

lifflander opened this issue Jun 21, 2020 · 3 comments · May be fixed by #1875

Comments

@lifflander
Copy link
Collaborator

What Needs to be Done?

VT is very aggressive with using const& to pass small types...i.e. basic types around. It's extra overhead reading the code and might even slow it down because the compiler has to preserve the memory address. Switch these to just const?

@pnstickne
Copy link
Contributor

pnstickne commented Jun 23, 2020

Should not use const& on any types <= 64bits, in general. Probably no loss in pref up to ~128bits. Numbers online indicate ~12bytes being some trade-off. YMMV on many factors. Compilers may also elect to ignore the const& in certain cases.

MsgPtr etc. is small exception as it allows bypassing ref count management, eg.

@lifflander lifflander added this to Unassigned in VT Sep 22, 2020
@cz4rs
Copy link
Contributor

cz4rs commented Sep 6, 2021

If possible, this should be detected automatically in CI.
Also consider compiler optimizations.

@jstrzebonski
Copy link
Contributor

I wonder if we could use clang-tidy for that? Or at least for reporting the occurrences of such const refs.

@jstrzebonski jstrzebonski self-assigned this May 10, 2022
@jstrzebonski jstrzebonski moved this from Unassigned to To do in VT May 10, 2022
@jstrzebonski jstrzebonski moved this from To do to In progress in VT Jun 2, 2022
jstrzebonski pushed a commit that referenced this issue Jul 20, 2022
jstrzebonski pushed a commit that referenced this issue Nov 9, 2022
@jstrzebonski jstrzebonski removed their assignment Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
VT
  
In progress
Development

Successfully merging a pull request may close this issue.

4 participants