Skip to content

Cache type hints - #46

Merged
the-glu merged 1 commit into
interuss:mainfrom
Orbitalize:cache_type_hints
Nov 26, 2026
Merged

the-glu merged 1 commit into
interuss:mainfrom
Orbitalize:cache_type_hints

Conversation

@the-glu

@the-glu the-glu commented Nov 25, 2026

Copy link
Copy Markdown
Member

Validating DSS releases, some interuss/monitoring's benchmark start to hit limits of the benchmarking machine rather than the limits of the tested pool.

This is part of optimizations that can be done without switching to a complex, full multi-process tests.

Most of implicit dict repetitive parsing during thoses benchmark are spent in retrieving type hints, who don't change during a type's life time. This just cache it.

Impact on benchmarks is very high: flight volume conversion to implicit dict objects for the API that was taking ~13.5% of the main thread drop to 2.7% with this patch:

image image

Synthetic benchmark on a regular object show improments as well:

ImplicitDict.parse(ChangeOperationalIntentReferenceResponse): 359.3 µs per parse
ImplicitDict.parse(ChangeOperationalIntentReferenceResponse): 92.8 µs per parse
import time

from implicitdict import ImplicitDict
from uas_standards.astm.f3548.v21.api import ChangeOperationalIntentReferenceResponse

N = 10000

response = {
    "operational_intent_reference": {
        "id": "6b9eaef8-99a7-4a0e-80a8-71f3998d85f0",
        "manager": "benchmarker",
        "uss_availability": "Unknown",
        "version": 1,
        "state": "Accepted",
        "ovn": "6b9eaef8-99a7-4a0e-80a8-71f3998d85f0_01a20f86-6afa-7ea9-a370-682c8afc327a",
        "time_start": {"value": "2026-11-25T14:00:00Z", "format": "RFC3339"},
        "time_end": {"value": "2026-11-25T14:00:15Z", "format": "RFC3339"},
        "uss_base_url": "https://testdummy.interuss.org/interuss/monitoring/benchmarker",
        "subscription_id": "48ff9727-d204-4cc3-9b7a-000000000000",
    },
    "subscribers": [
        {
            "subscriptions": [
                {
                    "subscription_id": "48ff9727-d204-4cc3-9b7a-000000000000",
                    "notification_index": 42,
                }
            ],
            "uss_base_url": "https://testdummy.interuss.org/interuss/monitoring/benchmarker",
        }
    ],
}

ImplicitDict.parse(response, ChangeOperationalIntentReferenceResponse)
t0 = time.perf_counter()
for _ in range(N):
    ImplicitDict.parse(response, ChangeOperationalIntentReferenceResponse)
dt = time.perf_counter() - t0
print(
    f"ImplicitDict.parse(ChangeOperationalIntentReferenceResponse): {dt / N * 1e6:.1f} µs per parse"
)

@mickmis mickmis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo addressing points raised in comment.

Comment thread src/implicitdict/__init__.py Resolved
@the-glu
the-glu requested a review from mickmis November 26, 2026 11:29

@mickmis mickmis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/implicitdict/__init__.py Resolved
@the-glu
the-glu merged commit f195c7c into interuss:main Nov 26, 2026
9 checks passed
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.

2 participants