https://github.com/daanv2/go-optimal
A simple, fast, and easy-to-use library for optimally creating and handling data and slices.
https://github.com/daanv2/go-optimal
cache concurrency go golang mit optimal parrallel slice
Last synced: 2 months ago
JSON representation
A simple, fast, and easy-to-use library for optimally creating and handling data and slices.
- Host: GitHub
- URL: https://github.com/daanv2/go-optimal
- Owner: DaanV2
- License: mit
- Created: 2022-12-18T10:04:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-28T15:41:08.000Z (about 1 year ago)
- Last Synced: 2025-04-19T18:07:10.106Z (10 months ago)
- Topics: cache, concurrency, go, golang, mit, optimal, parrallel, slice
- Language: Go
- Homepage: https://pkg.go.dev/github.com/daanv2/go-optimal
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Optimal


[](https://github.com/daanv2/go-optimal/actions/workflows/go-checks.yml)
A simple, fast, and easy-to-use library for optimally creating and handling data.
```bash
go get github.com/daanv2/go-optimal
```
## Examples
```go
// SliceSize returns the size that a slice should be to fit in the target cache
sliceSize := optimal.SliceSize[T]()
cpu.GetCPUInfo()
// These functions will be done in parralel, optimally splitting the work
parallel.ForEach()
parallel.Map()
parallel.All()
```
## Documentation
The documentation can be found [go dev](https://pkg.go.dev/github.com/daanv2/go-optimal) or [here](https://github.com/daanv2/go-optimal/tree/main/doc).
# Environment Variables / Settings
| Variable | Optional | Documentation |
| ------------------------ | -------- | ----------------------------------------------------------------------------------------------- |
| `CPU_CACHE_L1` | `true` | Cache L1 size in bytes, When set overrides the scraped value |
| `CPU_CACHE_L2` | `true` | Cache L2 size in bytes, When set overrides the scraped value |
| `CPU_CACHE_L3` | `true` | Cache L3 size in bytes, When set overrides the scraped value |
| `CPU_CACHE_OPTIMAL_SIZE` | `true` | Optimal cache size in bytes, When set overrides the scraped value |
| `CPU_CACHE_TARGET` | `true` | What type of cache to target, can be L1, L2, L3, anything else and it will determine on its own |