This commit adds a tool to analyze memory allocation patterns from wolfSSL operations and recommend optimal static memory bucket configurations to minimize wasted memory. The tool includes: - Memory bucket optimizer that analyzes allocation logs - Example application demonstrating optimized bucket usage - Visualization scripts using gnuplot - Scripts to run optimization for different TLS operations The tool helps users find optimal WOLFMEM_BUCKETS and WOLFMEM_DIST configurations for their specific use cases. Co-Authored-By: jacob@wolfssl.com <jacob@wolfssl.com> |
||
---|---|---|
.. | ||
examples | ||
src | ||
visualization | ||
.gitignore | ||
Makefile | ||
README.md | ||
run_multiple.sh | ||
run_optimizer.sh |
README.md
Memory Bucket Optimizer for wolfSSL Static Memory
This tool analyzes memory allocation patterns from wolfSSL operations and recommends optimal static memory bucket configurations to minimize wasted memory.
Software Bill of Materials (SBOM)
Component | Version | License | Purpose |
---|---|---|---|
wolfSSL | 5.6.6 | GPLv2 | TLS/SSL library with static memory support |
gnuplot | 5.4+ | gnuplot license | Data visualization |
gcc | 9.4+ | GPLv3 | C compiler |
GNU Make | 4.2+ | GPLv3 | Build system |
Stack Components
-
Memory Bucket Optimizer
- Analyzes memory allocation logs
- Recommends optimal bucket sizes
- Generates visualization plots
-
wolfSSL Integration
- Uses wolfSSL's static memory feature
- Configures memory buckets via WOLFMEM_BUCKETS and WOLFMEM_DIST
- Requires wolfSSL built with --enable-staticmemory
-
Visualization Tools
- gnuplot scripts for data visualization
- Memory usage analysis plots
- Bucket optimization charts
Building and Running
-
Build wolfSSL with static memory and logging:
cd ../../../wolfssl ./autogen.sh ./configure --enable-staticmemory --enable-memorylog make
-
Build the memory bucket optimizer:
cd ../wolfssl-examples/staticmemory/memory-bucket-optimizer make
-
Run the optimizer:
./run_optimizer.sh
-
Generate visualization plots:
cd visualization ./generate_data.sh
Directory Structure
memory-bucket-optimizer/
├── src/ # Source code
├── visualization/ # Visualization scripts
├── examples/ # Example applications
├── Makefile # Build system
├── run_optimizer.sh # Main script
└── README.md # This file
Usage
-
Basic Usage
./run_optimizer.sh
-
Optimize for Multiple TLS Operations
./optimize_multiple.sh
-
Verify Optimization Results
./verify_optimization.sh
Output
The tool generates:
- Optimized bucket configurations (WOLFMEM_BUCKETS and WOLFMEM_DIST)
- Memory usage analysis plots
- Comparison of different TLS operations
- Memory allocation pattern visualizations
Example Output
/* Optimized bucket configuration */
#define WOLFMEM_BUCKETS 16,22,30,40,86,133,184,256,344,512,864,1248,1812,3128,5518,8368
#define WOLFMEM_DIST 2,3,7,7,7,7,7,7,7,7,7,7,8,8,8,8
License
This example is part of wolfSSL examples and is licensed under the same terms as wolfSSL. See the LICENSE file in the wolfSSL root directory for details.