a technique that uses a buffer to minimize direct read and write operations to the disk. Golang's bufio package provides this functionality, allowing you to wrap your file objects in a buffered reader or writer. This can significantly speed up I/O operations by reducing the number of system calls.
you need to copy large files, io.Copy is your friend. It's optimized for copying data from one source to another using a fixed-size buffer. This method is efficient because it avoids loading the entire file into memory.
model makes it simple to perform I/O operations in parallel. By using goroutines and channels, you can process parts of a file concurrently, which is especially beneficial for CPU-bound I/O tasks.
interfaces allow you to define behavior contracts. When you use interfaces, the compiler can often generate efficient code that directly calls the underlying methods. Goroutines: Goroutines are threads that make concurrency easy in Go. The overhead of creating and managing goroutines is minimal, allowing you to create thousands or even millions of them. Slices: Go's slice operations are highly optimized, and working with slices is often as efficient as working with raw arrays. * https://ueokande.github.io/go-slice-tricks/
used functions to be placed inside the code by the compiler to eliminate the cost of calls. This avoids stack operations caused by function calls. Key Points: Reduces function call cost. Improves performance in loops or performance critical code blocks.
Calls: With pre-allocated capacity, the slice does not need to dynamically grow, which reduces the number of garbage collection-related memory allocations. Better Performance
careful consideration of the struct fields we need. This approach optimizes the memory blocks pre-allocated by the Go compiler based on the data types used in struct fields, ensuring efficient memory usage.
efficiency from the structs that we allocate continuously. In addition, this allows the CPU to easily navigate through the memory and perform pinpoint addressing. CLI Tool for Examine structs: dkorunic/betteralign