Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version: 1.1.0 → 1.2.0 (MINOR)
Summary
This MR addresses three performance bottlenecks and one observability gap: uncached metadata fetches, unbounded in-memory result loading, a scalar-only C++ resize path with Python list copy overhead, and a health endpoint that hardcoded its version and performed no dependency checks.
Changes
In-memory metadata cache
CachedImageRepositorydecorator (infrastructure layer) wrappingPostgresImageRepositorywith a thread-safe, TTL-based in-memory cache forget_by_idlookups.saveanddeleteto maintain consistency;list_images,count, andget_expiredpass through uncached.IMG_CACHE_TTL_SECONDS(default 60) andIMG_CACHE_MAX_SIZE(default 1024).Server-side cursors for list queries
list_images()andget_expired()switched fromsession.execute()+.scalars().all()tosession.stream_scalars()with async iteration, using PostgreSQL server-side cursors to avoid loading entire result sets into memory.C++ SIMD optimization and zero-copy I/O
bilinear_resizenow uses SSE2 intrinsics on x86-64 to interpolate all channels per pixel in parallel (__m128float ops), with a scalar fallback for other architectures.std::vector<uint8_t>(copied element-by-element from/to Python lists) topy::array_t<uint8_t>(zero-copy NumPy arrays).-march=nativefor host-optimal SIMD codegen.Health endpoint enhancements
importlib.metadata(sourced from pyproject.toml) instead of hardcoding"1.0.0".SELECT 1) and storage directory existence.checksmap with per-componentstatus/detail; overall status is"degraded"if any check fails.Files changed (14 files, +585 −53)
stream_scalarsfor list queriesComponentCheckmodel,checksfieldcache_ttl_seconds,cache_max_sizesettingspy::array_tI/O-march=native[1.2.0]sectionValidation
ruff check src/ tests/— all passedruff format src/ tests/— all formattedmypy src/— 0 issues (43 files)pytest --cov=src— 46/46 passed, 80% coverage-Wall -Wextra, runtime verified with RGB/RGBA arrays