Skip to content

Improve Docker image container counting - #972

Open
Alessio1210 wants to merge 1 commit into
Checkmk:masterfrom
Alessio1210:improve-docker-image-counting
Open

Alessio1210 wants to merge 1 commit into
Checkmk:masterfrom
Alessio1210:improve-docker-image-counting

Conversation

@Alessio1210

Copy link
Copy Markdown

General information

This change affects Docker host image inventory.

Proposed changes

The Docker inventory parser currently scans all containers for each image to determine its container count. Count image references once with collections.Counter and look up each image's count instead. This changes expected counting complexity from O(images * containers) to O(images + containers). Unused images still receive a count of zero.

Validation:

  • Docker test target passed in a fresh execution (81 tests).
  • Formatting, lint and mypy passed during local validation.
  • Compared HEAD and the working parser on six edge-case datasets, including shared images, unused images, unknown image references, duplicate container IDs and malformed JSON rows; results matched.

A local synthetic benchmark included JSON decoding and header validation. It extracted the parser and its helpers from HEAD and the working file; plugin registration and the rest of the Checkmk runtime were excluded. Seven paired samples per size used alternating execution order. Median wall times on Arch Linux, host Python 3.14.10:

Images Containers Before After Speedup
10 20 0.095 ms 0.087 ms 1.10x
100 1,000 3.39 ms 2.27 ms 1.49x
1,000 10,000 134.85 ms 27.31 ms 4.94x

These measurements describe this parser with synthetic inputs, not end-to-end performance. Small-host differences are too small to support a meaningful performance claim. The project tests ran in Bazel's environment; the standalone benchmark used the host Python.

No incorrect container counts or production incident are claimed. This is a performance optimization with unchanged output. No new repository tests were added; existing Docker tests pass.

Grüße,
Alessio Betz :)

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Alessio1210

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant