Skip to content

Commit e54df29

Browse files
committed
add note of cppcon
1 parent 5b1b07d commit e54df29

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

_code/CppCon/2024/hidden_overhead_of_a_function_api.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,30 @@ Order of parameters is fixed in every ABI.
150150
ref: Not leacing Performance on the jump table Eduardo Madrid in cppcon
151151

152152
> Do not pass an array as a single pointer.
153+
> Keep the number of function arguments low.
153154
155+
Reason: Having many arguments opens opportunities for confusion. Passing lots of arguments is often costly compared to alternatives.
154156

157+
Triple product: all int or vector 3
158+
159+
ref: Keep an eye out for buffer security checks
160+
161+
For all int there is a lot of moving.
162+
163+
And stack pointer is heavily used.
164+
165+
Number of Register is limited.
166+
167+
## Conclusion
168+
169+
- Compilers do unexpected thing to your code, because they have to follow all the specification.
170+
- Compiler Explorer is you friend.
171+
- C++ Core Guidelines are pretty reasonable from performance point of view.
172+
173+
Guidelines:
174+
175+
- Return by value
176+
- Pass trivial types by value, oters by reference
177+
- Follow the rule of 0, or support trivial copy
178+
- Make APIs consistent
179+
- Understand abstraction cost on your target platform

0 commit comments

Comments
 (0)