diff --git a/measurements/expe001.5/readme.md b/measurements/expe001.5/readme.md index 5a31742..56c0e5b 100644 --- a/measurements/expe001.5/readme.md +++ b/measurements/expe001.5/readme.md @@ -1,7 +1,32 @@ -find relations between meminfo variables using [/home/graffy/work/linuxram.git/src/sumfinder.py] +find relations between meminfo variables using [/home/graffy/work/linuxram.git/src/expe001.5.py] ```sh -20240814-15:22:42 graffy@graffy-ws2:~/work/linuxram.git/measurements/expe001.5$ ../../src/sumfinder.py +20240814-16:19:42 graffy@graffy-ws2:~/work/linuxram.git/measurements/expe001.5$ ../../src/expe001.5-set001.py +set of integer variables to explore: [c: 11, b: 8, h: 7, g: 6, d: 5, a: 3, f: 2, e: 1] +sum found: c = d + a + f + e +sum found: c = g + a + f +sum found: c = g + d +sum found: c = h + a + e +sum found: c = b + f + e +sum found: c = b + a +sum found: b = d + f + e +sum found: b = d + a +sum found: b = g + f +sum found: b = h + e +sum found: h = d + f +sum found: h = g + e +sum found: g = a + f + e +sum found: g = d + e +sum found: d = a + f +sum found: a = f + e +exporting sums to set001-sums.json +creating set001-sums.dot from set001-sums.json +creating set001-sums.svg from set001-sums.dot +last command status : [0] +``` + +```sh +20240814-15:22:42 graffy@graffy-ws2:~/work/linuxram.git/measurements/expe001.5$ ../../src/expe001.5-alambix97.py set of integer variables to explore: [MemTotal: 201214205952, DirectMap1G: 199715979264, Committed_AS: 141631254528, CommitLimit: 133373001728, MemAvailable: 131466833920, Cached: 130939863040, Active: 103304773632, Inactive: 94177337344, Inactive(file): 67258384384, AnonPages: 65442127872, Active(file): 63633461248, AnonHugePages: 49218060288, Active(anon): 39671312384, SwapTotal: 32765898752, Inactive(anon): 26918952960, Dirty: 8546779136, DirectMap2M: 6434062336, Slab: 1991671808, KReclaimable: 1252827136, SReclaimable: 1252827136, SwapCached: 1088724992, MemFree: 803061760, SUnreclaim: 738844672, DirectMap4k: 554131456, VmallocUsed: 302333952, PageTables: 218902528, Percpu: 215089152, Mapped: 120565760, Shmem: 69955584, Buffers: 31981568, Unevictable: 23019520, Mlocked: 19873792, KernelStack: 17088512, Writeback: 5550080, Hugepagesize: 2097152, HardwareCorrupted: 53248] sum found: MemTotal = Active(file) + AnonHugePages + Active(anon) + Inactive(anon) + Dirty + DirectMap2M + Slab + SReclaimable + SwapCached + MemFree + SUnreclaim + VmallocUsed + PageTables + Percpu + Mapped + Buffers + Mlocked + Writeback + Hugepagesize + HardwareCorrupted sum found: MemTotal = Active(file) + AnonHugePages + Active(anon) + Inactive(anon) + Dirty + DirectMap2M + Slab + SReclaimable + SwapCached + MemFree + SUnreclaim + DirectMap4k + VmallocUsed + Unevictable + Mlocked + KernelStack diff --git a/measurements/expe001.5/set001-sums.dot b/measurements/expe001.5/set001-sums.dot new file mode 100644 index 0000000..2217f3e --- /dev/null +++ b/measurements/expe001.5/set001-sums.dot @@ -0,0 +1,29 @@ +digraph set001_sums +{ +layout = neato +overlap = false +h [label="h=7"]; +b [label="b=8"]; +c [label="c=11"]; +e [label="e=1"]; +f [label="f=2"]; +a [label="a=3"]; +d [label="d=5"]; +g [label="g=6"]; +c -> {d,a,f,e} [color=aliceblue, label=0]; +c -> {g,a,f} [color=antiquewhite, label=1]; +c -> {g,d} [color=aqua, label=2]; +c -> {h,a,e} [color=aquamarine, label=3]; +c -> {b,f,e} [color=azure, label=4]; +c -> {b,a} [color=beige, label=5]; +b -> {d,f,e} [color=bisque, label=6]; +b -> {d,a} [color=black, label=7]; +b -> {g,f} [color=blanchedalmond, label=8]; +b -> {h,e} [color=blue, label=9]; +h -> {d,f} [color=blueviolet, label=10]; +h -> {g,e} [color=brown, label=11]; +g -> {a,f,e} [color=burlywood, label=12]; +g -> {d,e} [color=cadetblue, label=13]; +d -> {a,f} [color=chartreuse, label=14]; +a -> {f,e} [color=chocolate, label=15]; +} diff --git a/measurements/expe001.5/set001-sums.json b/measurements/expe001.5/set001-sums.json new file mode 100644 index 0000000..ee7f8b2 --- /dev/null +++ b/measurements/expe001.5/set001-sums.json @@ -0,0 +1 @@ +{"format": "sums-v001", "variables": {"d": 5, "c": 11, "a": 3, "g": 6, "h": 7, "b": 8, "e": 1, "f": 2}, "sums": [{"total": "c", "components": ["d", "a", "f", "e"]}, {"total": "c", "components": ["g", "a", "f"]}, {"total": "c", "components": ["g", "d"]}, {"total": "c", "components": ["h", "a", "e"]}, {"total": "c", "components": ["b", "f", "e"]}, {"total": "c", "components": ["b", "a"]}, {"total": "b", "components": ["d", "f", "e"]}, {"total": "b", "components": ["d", "a"]}, {"total": "b", "components": ["g", "f"]}, {"total": "b", "components": ["h", "e"]}, {"total": "h", "components": ["d", "f"]}, {"total": "h", "components": ["g", "e"]}, {"total": "g", "components": ["a", "f", "e"]}, {"total": "g", "components": ["d", "e"]}, {"total": "d", "components": ["a", "f"]}, {"total": "a", "components": ["f", "e"]}]} \ No newline at end of file diff --git a/measurements/expe001.5/set001-sums.svg b/measurements/expe001.5/set001-sums.svg new file mode 100644 index 0000000..9b739a7 --- /dev/null +++ b/measurements/expe001.5/set001-sums.svg @@ -0,0 +1,334 @@ + + + + + + +set001_sums + + + +h + +h=7 + + + +e + +e=1 + + + +h->e + + +11 + + + +f + +f=2 + + + +h->f + + +10 + + + +d + +d=5 + + + +h->d + + +10 + + + +g + +g=6 + + + +h->g + + +11 + + + +b + +b=8 + + + +b->h + + +9 + + + +b->e + + +6 + + + +b->e + + +9 + + + +b->f + + +6 + + + +b->f + + +8 + + + +a + +a=3 + + + +b->a + + +7 + + + +b->d + + +6 + + + +b->d + + +7 + + + +b->g + + +8 + + + +c + +c=11 + + + +c->h + + +3 + + + +c->b + + +4 + + + +c->b + + +5 + + + +c->e + + +0 + + + +c->e + + +3 + + + +c->e + + +4 + + + +c->f + + +0 + + + +c->f + + +1 + + + +c->f + + +4 + + + +c->a + + +0 + + + +c->a + + +1 + + + +c->a + + +3 + + + +c->a + + +5 + + + +c->d + + +0 + + + +c->d + + +2 + + + +c->g + + +1 + + + +c->g + + +2 + + + +a->e + + +15 + + + +a->f + + +15 + + + +d->f + + +14 + + + +d->a + + +14 + + + +g->e + + +12 + + + +g->e + + +13 + + + +g->f + + +12 + + + +g->a + + +12 + + + +g->d + + +13 + + + diff --git a/src/expe001.5-alambix97.py b/src/expe001.5-alambix97.py new file mode 100755 index 0000000..ef3e504 --- /dev/null +++ b/src/expe001.5-alambix97.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# given a list of integer variables and their values, this tool aims at finding which varibales can be obtained by the sum of others +# note : this tool is used to find the sums in the variables output by /proc/meminfo +from sumfinder import find_and_graph_sums + + +def get_test_set_002(): + # alambix97/20240805-191606-meminfo.stdout + return {'MemTotal': 201214205952, 'MemFree': 803061760, 'MemAvailable': 131466833920, 'Buffers': 31981568, 'Cached': 130939863040, 'SwapCached': 1088724992, 'Active': 103304773632, 'Inactive': 94177337344, 'Active(anon)': 39671312384, 'Inactive(anon)': 26918952960, 'Active(file)': 63633461248, 'Inactive(file)': 67258384384, 'Unevictable': 23019520, 'Mlocked': 19873792, 'SwapTotal': 32765898752, 'Dirty': 8546779136, 'Writeback': 5550080, 'AnonPages': 65442127872, 'Mapped': 120565760, 'Shmem': 69955584, 'KReclaimable': 1252827136, 'Slab': 1991671808, 'SReclaimable': 1252827136, 'SUnreclaim': 738844672, 'KernelStack': 17088512, 'PageTables': 218902528, 'CommitLimit': 133373001728, 'Committed_AS': 141631254528, 'VmallocTotal': 35184372087808, 'VmallocUsed': 302333952, 'Percpu': 215089152, 'HardwareCorrupted': 53248, 'AnonHugePages': 49218060288, 'Hugepagesize': 2097152, 'DirectMap4k': 554131456, 'DirectMap2M': 6434062336, 'DirectMap1G': 199715979264} + + +def get_test_set_003(): + # same as test_set_002 but without VmallocTotal which for some reason causes the program to become extremeley slow (maybe because it's a huge integer ?) + return {'MemTotal': 201214205952, 'MemFree': 803061760, 'MemAvailable': 131466833920, 'Buffers': 31981568, 'Cached': 130939863040, 'SwapCached': 1088724992, 'Active': 103304773632, 'Inactive': 94177337344, 'Active(anon)': 39671312384, 'Inactive(anon)': 26918952960, 'Active(file)': 63633461248, 'Inactive(file)': 67258384384, 'Unevictable': 23019520, 'Mlocked': 19873792, 'SwapTotal': 32765898752, 'Dirty': 8546779136, 'Writeback': 5550080, 'AnonPages': 65442127872, 'Mapped': 120565760, 'Shmem': 69955584, 'KReclaimable': 1252827136, 'Slab': 1991671808, 'SReclaimable': 1252827136, 'SUnreclaim': 738844672, 'KernelStack': 17088512, 'PageTables': 218902528, 'CommitLimit': 133373001728, 'Committed_AS': 141631254528, 'VmallocUsed': 302333952, 'Percpu': 215089152, 'HardwareCorrupted': 53248, 'AnonHugePages': 49218060288, 'Hugepagesize': 2097152, 'DirectMap4k': 554131456, 'DirectMap2M': 6434062336, 'DirectMap1G': 199715979264} + + +def main(): + find_and_graph_sums(get_test_set_003(), 'alambix97-meminfo') + + +main() diff --git a/src/expe001.5-set001.py b/src/expe001.5-set001.py new file mode 100755 index 0000000..6eb0a46 --- /dev/null +++ b/src/expe001.5-set001.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +from sumfinder import find_and_graph_sums + + +def get_test_set_001(): + return { + 'a': 3, + 'b': 8, + 'c': 11, + 'd': 5, + 'e': 1, + 'f': 2, + 'g': 6, + 'h': 7 + } + + +def main(): + find_and_graph_sums(get_test_set_001(), 'set001') + + +main() diff --git a/src/sumfinder/__init__.py b/src/sumfinder/__init__.py new file mode 100644 index 0000000..fb42929 --- /dev/null +++ b/src/sumfinder/__init__.py @@ -0,0 +1,4 @@ +from .sumfinder import SumExporter # noqa +from .sumfinder import find_sums # noqa +from .sumfinder import sums_to_dot # noqa +from .sumfinder import find_and_graph_sums # noqa diff --git a/src/sumfinder.py b/src/sumfinder/sumfinder.py similarity index 77% rename from src/sumfinder.py rename to src/sumfinder/sumfinder.py index 91791a2..af86148 100755 --- a/src/sumfinder.py +++ b/src/sumfinder/sumfinder.py @@ -280,29 +280,6 @@ def sums_to_dot(sum_file_path: Path, dot_file_path: Path): dot_file.write('}\n') -def get_test_set_001(): - return { - 'a': 3, - 'b': 8, - 'c': 11, - 'd': 5, - 'e': 1, - 'f': 2, - 'g': 6, - 'h': 7 - } - - -def get_test_set_002(): - # alambix97/20240805-191606-meminfo.stdout - return {'MemTotal': 201214205952, 'MemFree': 803061760, 'MemAvailable': 131466833920, 'Buffers': 31981568, 'Cached': 130939863040, 'SwapCached': 1088724992, 'Active': 103304773632, 'Inactive': 94177337344, 'Active(anon)': 39671312384, 'Inactive(anon)': 26918952960, 'Active(file)': 63633461248, 'Inactive(file)': 67258384384, 'Unevictable': 23019520, 'Mlocked': 19873792, 'SwapTotal': 32765898752, 'Dirty': 8546779136, 'Writeback': 5550080, 'AnonPages': 65442127872, 'Mapped': 120565760, 'Shmem': 69955584, 'KReclaimable': 1252827136, 'Slab': 1991671808, 'SReclaimable': 1252827136, 'SUnreclaim': 738844672, 'KernelStack': 17088512, 'PageTables': 218902528, 'CommitLimit': 133373001728, 'Committed_AS': 141631254528, 'VmallocTotal': 35184372087808, 'VmallocUsed': 302333952, 'Percpu': 215089152, 'HardwareCorrupted': 53248, 'AnonHugePages': 49218060288, 'Hugepagesize': 2097152, 'DirectMap4k': 554131456, 'DirectMap2M': 6434062336, 'DirectMap1G': 199715979264} - - -def get_test_set_003(): - # same as test_set_002 but without VmallocTotal which for some reason causes the program to become extremeley slow (maybe because it's a huge integer ?) - return {'MemTotal': 201214205952, 'MemFree': 803061760, 'MemAvailable': 131466833920, 'Buffers': 31981568, 'Cached': 130939863040, 'SwapCached': 1088724992, 'Active': 103304773632, 'Inactive': 94177337344, 'Active(anon)': 39671312384, 'Inactive(anon)': 26918952960, 'Active(file)': 63633461248, 'Inactive(file)': 67258384384, 'Unevictable': 23019520, 'Mlocked': 19873792, 'SwapTotal': 32765898752, 'Dirty': 8546779136, 'Writeback': 5550080, 'AnonPages': 65442127872, 'Mapped': 120565760, 'Shmem': 69955584, 'KReclaimable': 1252827136, 'Slab': 1991671808, 'SReclaimable': 1252827136, 'SUnreclaim': 738844672, 'KernelStack': 17088512, 'PageTables': 218902528, 'CommitLimit': 133373001728, 'Committed_AS': 141631254528, 'VmallocUsed': 302333952, 'Percpu': 215089152, 'HardwareCorrupted': 53248, 'AnonHugePages': 49218060288, 'Hugepagesize': 2097152, 'DirectMap4k': 554131456, 'DirectMap2M': 6434062336, 'DirectMap1G': 199715979264} - - def find_and_graph_sums(variables: Dict[str, int], set_id: str): # set_id: eg 'set001' 'alambix97-meminfo' sums_file_path = Path(f'{set_id}-sums.json') @@ -313,11 +290,3 @@ def find_and_graph_sums(variables: Dict[str, int], set_id: str): sums_to_dot(sums_file_path, dot_file_path) print(f'creating {svg_file_path} from {dot_file_path}') subprocess.run(f'dot -Tsvg {dot_file_path} > {svg_file_path}', shell=True, check=True) - - -def main(): - # find_and_graph_sums(get_test_set_001(), 'set001') - find_and_graph_sums(get_test_set_003(), 'alambix97-meminfo') - - -main()