https://github.com/esotuvaka/memetic
Memetic is a CLI tool for memory layout analysis across multiple compiled languages. It can recursively search your directories for structs and suggest more optimal memory layouts. Useful for memory constrained deployments, high-performance apps, embedded programming, FFI interoperability, etc.
https://github.com/esotuvaka/memetic
c cli cpp embedded-systems ffi go memory-analyzer rust struct
Last synced: 3 months ago
JSON representation
Memetic is a CLI tool for memory layout analysis across multiple compiled languages. It can recursively search your directories for structs and suggest more optimal memory layouts. Useful for memory constrained deployments, high-performance apps, embedded programming, FFI interoperability, etc.
- Host: GitHub
- URL: https://github.com/esotuvaka/memetic
- Owner: esotuvaka
- License: mit
- Created: 2024-12-23T08:48:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-12T19:49:11.000Z (over 1 year ago)
- Last Synced: 2025-06-02T06:34:43.933Z (about 1 year ago)
- Topics: c, cli, cpp, embedded-systems, ffi, go, memory-analyzer, rust, struct
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# Memetic
Memetic is a Rust CLI tool designed to read source code files, find the structs, analyze their memory layout, and suggest optimizations for a more optimal memory footprint. It provides a formatted output or a git diff to show the suggested changes.
## Features
- **Recursive File Search**: Search for source code files starting from the directory the CLI is called in.
- **Struct Analysis**: Identify and analyze the memory layout of structs in the source code.
- **Optimization Suggestions**: Suggest a more optimal memory footprint for the structs, if any.
- **Formatted Output**: Display the optimized memory layout in a readable format.
- **Git Diff**: Show the suggested changes as a git diff.
## Installation
NOTE: Currently no full release yet, so will have to be built from source.
To install `memetic`, you need to have Rust and Cargo installed. Then, you can build the project using Cargo:
```sh
cargo build --release
```
## Usage
Run `memetic` with the following command:
```sh
memetic [OPTIONS]
```
### Options
- -m mode: (E)xecute, (S)uggest, (D)iff using Git
- -o override: Pass a json object that overrides defaults. e.g: {"type": "u32", "nat_align": 5, "size": 8}
- -i includes: operate on files matching a comma separated list of regex patterns, instead of recursively
- -e excludes: exclude files matching a comma separated list of regex patterns from recursive search
- -d directory: operate from some starting directory, given some relative path to it. e.g: "./src"
## Examples
To analyze all files in the current directory and suggest optimizations:
```sh
memetic -a -m suggest
```
To auto implement changes over a nested directory, excluding 2 files:
```sh
memetic -m execute -d ./src/routers -e users.rs,messages.rs # note the lack of space between files
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.