Add copyright notices and comprehensive documentation
Co-Authored-By: jacob@wolfssl.com <jacob@wolfssl.com>devin/1741050294-optimize-memory-buckets
parent
5b99a977e5
commit
abb76a4089
|
@ -1,4 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2025 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL.
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
|
||||
|
||||
# Script to generate test memory logs and run the optimizer
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# Memory Bucket Optimizer Source Code
|
||||
|
||||
This directory contains the source code for the Memory Bucket Optimizer tool.
|
||||
|
||||
## Software Bill of Materials (SBOM)
|
||||
|
||||
| Component | Description | License |
|
||||
|-----------|-------------|---------|
|
||||
| Memory Bucket Optimizer | Core optimization tool | GPLv2 |
|
||||
| GCC | C compiler | GPLv3 |
|
||||
|
||||
## Stack Components
|
||||
|
||||
The Memory Bucket Optimizer tool analyzes memory allocation patterns in wolfSSL and recommends optimal static memory bucket configurations to minimize wasted memory. The stack components include:
|
||||
|
||||
1. **Memory Bucket Optimizer**: The core optimization tool
|
||||
2. **GCC**: The C compiler used to build the tool
|
||||
|
||||
## Building
|
||||
|
||||
To build the Memory Bucket Optimizer tool, run:
|
||||
|
||||
```bash
|
||||
cd ~/repos/wolfssl-examples/staticmemory/memory-bucket-optimizer
|
||||
make
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To use the Memory Bucket Optimizer tool, run:
|
||||
|
||||
```bash
|
||||
./src/memory_bucket_optimizer <memory_log_file> > <output_file>
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
./src/memory_bucket_optimizer results/tls13_google_memory.txt > results/tls13_google_buckets.txt
|
||||
```
|
||||
|
||||
This will analyze the memory allocation patterns in the memory log file and generate optimized bucket configurations in the output file.
|
||||
|
||||
## Algorithm
|
||||
|
||||
The memory bucket optimizer uses the following algorithm:
|
||||
|
||||
1. Parse memory allocation logs to identify allocation sizes and frequencies
|
||||
2. Sort allocation sizes from smallest to largest
|
||||
3. Select the most frequent allocation sizes as bucket sizes
|
||||
4. Assign distribution values based on allocation frequency
|
||||
5. Calculate memory waste and optimize for minimal overhead
|
|
@ -1,4 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2025 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL.
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
|
||||
|
||||
# Script to test the memory bucket optimizer with different TLS operations
|
||||
|
||||
|
|
|
@ -1,4 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2025 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL.
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
|
||||
|
||||
# Script to test the memory bucket optimizer with different TLS operations
|
||||
|
||||
|
|
|
@ -1,4 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2025 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL.
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
|
||||
|
||||
# Script to generate data files and plots for memory bucket optimization
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls12_cloudflare_bucket_optimization.png"
|
||||
set title "Bucket Optimization for tls12_cloudflare"
|
||||
set xlabel "Size (bytes)"
|
||||
set ylabel "Count"
|
||||
set grid
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set key outside
|
||||
plot "data/tls12_cloudflare_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes", \
|
||||
"data/tls12_cloudflare_bucket_sizes.txt" using 1:(0.5) with impulses lw 2 title "Bucket Sizes"
|
|
@ -0,0 +1,10 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls12_cloudflare_allocation_histogram.png"
|
||||
set title "Allocation Size Distribution for tls12_cloudflare"
|
||||
set xlabel "Allocation Size (bytes)"
|
||||
set ylabel "Frequency"
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set grid
|
||||
set logscale y
|
||||
plot "data/tls12_cloudflare_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes"
|
|
@ -0,0 +1,11 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls13_cloudflare_bucket_optimization.png"
|
||||
set title "Bucket Optimization for tls13_cloudflare"
|
||||
set xlabel "Size (bytes)"
|
||||
set ylabel "Count"
|
||||
set grid
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set key outside
|
||||
plot "data/tls13_cloudflare_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes", \
|
||||
"data/tls13_cloudflare_bucket_sizes.txt" using 1:(0.5) with impulses lw 2 title "Bucket Sizes"
|
|
@ -0,0 +1,10 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls13_cloudflare_allocation_histogram.png"
|
||||
set title "Allocation Size Distribution for tls13_cloudflare"
|
||||
set xlabel "Allocation Size (bytes)"
|
||||
set ylabel "Frequency"
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set grid
|
||||
set logscale y
|
||||
plot "data/tls13_cloudflare_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes"
|
|
@ -0,0 +1,11 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls13_google_bucket_optimization.png"
|
||||
set title "Bucket Optimization for tls13_google"
|
||||
set xlabel "Size (bytes)"
|
||||
set ylabel "Count"
|
||||
set grid
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set key outside
|
||||
plot "data/tls13_google_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes", \
|
||||
"data/tls13_google_bucket_sizes.txt" using 1:(0.5) with impulses lw 2 title "Bucket Sizes"
|
|
@ -0,0 +1,10 @@
|
|||
set terminal png size 800,600
|
||||
set output "tls13_google_allocation_histogram.png"
|
||||
set title "Allocation Size Distribution for tls13_google"
|
||||
set xlabel "Allocation Size (bytes)"
|
||||
set ylabel "Frequency"
|
||||
set style fill solid 0.5
|
||||
set boxwidth 0.8
|
||||
set grid
|
||||
set logscale y
|
||||
plot "data/tls13_google_alloc_data.txt" using 2:1 with boxes title "Allocation Sizes"
|
Loading…
Reference in New Issue