Optimizing the code to achieve the best results in golang GC seems to be quite an important task recently with time-optimized GC sessions. Recently, they told me how much he will perform in the race "depends on your heap memory usage model." But I'm not quite sure what this means / implies from the point of view of a programmer in this language. Or is it not something that can be easily controlled?
I read the recent book, The Go Programming Language, by Brian W. Kernigan, but there is nothing in this topic. And all the information on this topic on the Internet already many years ago, so it really doesn’t apply.
Some of the things I'm doing right now include:
- Ensuring that pointers / objects are stored / remembered only where they need to be
- Select objects with expected or reasonable capabilities.
- No data duplication
- Whenever possible, use streaming data through functions instead of putting all the data in a large heap.
I'm also a little annoyed by the fact that strings and byte arrays are always recreated when converting between one or the other (due to immutability of strings). Therefore, when I switch from one to the other and its safe operation, I simply retell my pointers to another type using unsafe functions.
Are all of these methods worth helping the GC work faster and clearer? Is there anything else I could do?