Skip to content

KeyError: 'directory' when making --loggraph #166

@rkleinem

Description

@rkleinem

I see a KeyError: 'directory'.

Bug description

Whether it happens or not seems to depend on the dataset that you want to plot.
As such the error appears more-or-less randomly in my test setup.
However, it seems like it only affects --loggraph plots, but it is not specific to a --type or a --filter.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.13/site-packages/fio_plot/__main__.py", line 4, in <module>
    fio_plot.main()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/fio_plot/__init__.py", line 41, in main
    routing_dict[graphtype]["function"](settings, data)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/fio_plot/fiolib/graph2d.py", line 100, in chart_2d_log_data
    "maxlabelsize": support2d.get_max_label_size(settings, data),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/fio_plot/fiolib/graph2dsupporting.py", line 50, in get_max_label_size
    label = create_label(settings, item)
  File "/usr/local/lib/python3.13/site-packages/fio_plot/fiolib/graph2dsupporting.py", line 41, in create_label
    mydir = f"{item['directory']}"
               ~~~~^^^^^^^^^^^^^
KeyError: 'directory'

Observations

I printed the data in graph2d.py before it gets passed to support2d.get_max_label_size:

{'datatypes': ['bw'], 'dataset': [{'read': [(1000.75, 156569), (2000, 117876), (3000.25, 112640), (4000, 49200), (5000, 636928), (6000, 479710), (7000, 462283), (8000, 90112), (9000, 118784), (10000, 116851), (11000.5, 88064), (12000, 126076), (13000, 75776), (14000.5, 80896), (15000, 111725), (16000, 121975), (17000, 110592), (18000.75, 80896), (19000, 96350), (20000.5, 109568), (21000, 94300), (22000, 78848), (22999.75, 102500), (24750, 107520), (25750, 90182), (27000.5, 77876), (28249.75, 134276), (29250, 274614)], 'write': {'xvalues': [1.00075, 2.0, 3.0005, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0005, 12.0, 13.0, 14.0005, 15.0, 16.0, 17.0, 18.00075, 19.0, 20.0005, 21.0, 22.0, 22.99975, 24.75, 25.75, 27.0005, 27.99975, 29.0], 'yvalues': [184.873046875, 111.109375, 95.0, 55.0537109375, 670.0, 464.462890625, 507.5068359375, 82.0, 105.0, 120.1181640625, 77.0, 135.1328125, 102.0, 65.0, 102.099609375, 122.119140625, 98.0, 102.0, 104.1025390625, 110.0, 99.0966796875, 77.0, 109.107421875, 106.0, 106.0712890625, 79.0546875, 103.1005859375, 233.1533203125], 'ylabel': 'MB/s', 'max': np.float64(670.0), 'mean': 154, 'stdv': np.float64(92.63), 'percentile': 670}, 'hostname': None, 'type': 'bw', 'iodepth': 1, 'numjobs': 4, 'directory': '1M', 'xlabel': 'Time (s)'}, {'read': [(1750.125, 14181), (2000.875, 13492), (2001.875, 13492), (2002.875, 13492), (3252.875, 24888), (3253.875, 24888), (4378.75, 15420), (4379.75, 15420), (6878.625, 23331), (8877.75, 45907), (9753.5, 12601), (12628, 8605), (12878.75, 44071), (14753.75, 28312), (14879.625, 31890), (16004.625, 131607), (19627.5, 156227), (22375.75, 264379)], 'write': [], 'hostname': None}]}

Note the empty records. Sometimes it's only read or only write that is empty and sometimes it is both.

I don't have a good overview of the inner workings here, but I think I narrowed it down to
4a769b4
(1.1.15 seems to be the last version without the bug)
With that intendation the if len(record[rw]) > 0 check does not apply.

How to reproduce

To make the benchmarks I ran

python -m bench_fio --target=/app --output=/tmp/results/results --type=directory --destructive --size=50m --time-based --runtime=30 --mode=randrw --rwmixread=50 --block-size=1M --iodepth=1 --numjobs=4 --engine=psync --direct=0 --loginterval=1000
python -m bench_fio --target=/app --output=/tmp/results/results --type=directory --destructive --size=50m --time-based --runtime=30 --mode=randrw --rwmixread=50 --block-size=1M --iodepth=1 --numjobs=8 --engine=psync --direct=0 --loginterval=1000

I attached the outputs.

The call that fails is

python -m fio_plot --input-directory /tmp/results/results/app/randrw50/1M --title log-app-bw-randrw-bs1M --rw randrw --numjobs 4 8 --loggraph --filter write --xlabel-parent 0 --type bw

results.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions