mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Update CONTRIBUTING.md
I added a section on performance
This commit is contained in:
parent
f4e472c218
commit
0762e30955
@ -82,6 +82,22 @@ Often the simplest code is easier to read, easier to maintain and more efficient
|
||||
- Use the simplest data structure for the job: e.g. use a slice instead of List if you know the size upfront
|
||||
- Don't make things public if they don't need to be
|
||||
|
||||
## A note on performance optimizations
|
||||
|
||||
I like to follow Casey Muratori's optimization philosophy as outlined here: https://www.youtube.com/watch?v=pgoetgxecw8
|
||||
|
||||
The most important optimization technique he mentions is non-pessimization, not needlessly making things worse.
|
||||
This mostly overlaps with the points from above. Some example for this are:
|
||||
- use the right data structure (don't force the square block through the circular hole), this may seem trivial, but often as code grows you may find yourself in a situation where the original data structure doesn't really fit anymore
|
||||
- use the simplest data structure for the job, e.g. Use an array list or circular buffer instead of a linked list or queue
|
||||
- keep data/object dependencies at a minimum, if you can put things flat into memory or on the stack without a pointer on the heap, then that's simpler and faster.
|
||||
- use f32 if you don't need the precision of f64
|
||||
- don't store things as zon if they don't need to be human readable, just use binary
|
||||
- always lock mutexes in the tightest possible scope
|
||||
|
||||
The next important thing is to avoid fake optimizations, if you optimize something you must measure it in a realistic setting (and be mindful about measuring errors: https://www.youtube.com/watch?v=r-TLSBdHe1A ).
|
||||
Otherwise you may just end up with a more complicated and slower thing.
|
||||
|
||||
## Follow the style guide
|
||||
|
||||
Most of the syntax is handled by a modified version of zig fmt and checked by the CI (see the formatting section above).
|
||||
@ -128,5 +144,5 @@ With a quick check you can ensure that you didn't add any unintended changes.
|
||||
|
||||
With a more thorough review of your changes you can sometimes catch small mistakes, leftover TODOs or random debug code.
|
||||
|
||||
And of course make sure to check the CI results, you should also get an e-mail notification if the CI fails.
|
||||
And of course make sure to check the CI results, you should also get an e-mail notification if the CI fails. **I will not review a PR if the CI failed!**
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user