fix(): PICs improvements and reduce memory pressure - #1719
Conversation
…what is required for PICRequest processing to reduce memory pressure
📝 WalkthroughWalkthroughSteam license handling now uses a slim Room projection for PICS processing, batches license inserts with ChangesSteam license PICS flow
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/service/SteamService.kt (1)
4180-4182: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueOptional: Chunking is unnecessary for Room's
@Insert.While chunking
cachedLicenseDao.insertAllabove effectively saves memory by avoiding a massive list of serialized JSON strings all at once, chunkinglicenseDao.insertAllhere doesn't yield the same memory benefit becauselicensesToAddis already fully materialized in memory.Additionally, Room's
@Insertfor collections handles large lists gracefully without hitting SQLite's 999 parameter limit. It does this by compiling a singleINSERTstatement and executing it in a loop for each entity within the transaction, rather than expanding the entire list into a single massive query (unlikeIN (:list)queries).You can safely pass the entire list to
insertAllto avoid allocating intermediate chunk lists.♻️ Proposed refactor
- licensesToAdd.chunked(MAX_PICS_BUFFER).forEach { chunk -> - licenseDao.insertAll(chunk) - } + licenseDao.insertAll(licensesToAdd)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/main/java/app/gamenative/service/SteamService.kt` around lines 4180 - 4182, Update the license insertion flow around licenseDao.insertAll to pass licensesToAdd directly instead of iterating over chunked intermediate lists. Keep the existing insertion behavior unchanged while removing the unnecessary chunk allocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@app/src/main/java/app/gamenative/service/SteamService.kt`:
- Around line 4180-4182: Update the license insertion flow around
licenseDao.insertAll to pass licensesToAdd directly instead of iterating over
chunked intermediate lists. Keep the existing insertion behavior unchanged while
removing the unnecessary chunk allocation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f23cb5d5-333d-4143-82e7-2316dea16be3
📒 Files selected for processing (3)
app/src/main/java/app/gamenative/data/SteamLicenseForPics.ktapp/src/main/java/app/gamenative/db/dao/SteamLicenseDao.ktapp/src/main/java/app/gamenative/service/SteamService.kt
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
|
Is now encompassed by: #1721 But feel free to merge this first to reduce the overall size of that PR. |
…k, with dropped-batch self-healing Ports utkarshdalal#1721 (supersedes utkarshdalal#1719): - Slim Room projections (SteamAppPicsMeta, SteamLicenseStub, SteamLicenseForPics) so PICS collectors stop deserializing full blobs - onLicenseList: immediate in-memory licenses, 5s debounce for callback bursts, diff-based license writes, PICS queueing only for new/changed packages, atomic cached-license snapshot transaction - Batched DB reads in PICS app/package collectors (no per-app full-row reads); IN() queries chunked under SQLite's 999-var limit - 30s PICS job timeouts + bounded retries with backoff - Room: bounded query executor, two new steam_app indexes - LibraryViewModel: pagination fast path over the cached filtered list, cancellable filter/page jobs, precomputed sort keys, single installed- branch query, depot-size cache, hoisted credential checks Fork addition after quad review (code/perf/architect/KISS): PICS batches that exhaust retries are stashed and re-queued on the next license sync (fires on every login), restoring the self-healing the old requeue- everything behavior provided; otherwise a dropped batch would leave permanently stale package metadata.
Description
Recording
Type of Change
Checklist
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.CONTRIBUTING.md.Summary by cubic
Cuts memory use and stabilizes PICS requests by fetching only the needed license fields and matching chunk sizes to the PICS batch size.
SteamLicenseForPicsandgetLicensesForPics()to select onlypackageIdandaccess_token.MAX_PICS_BUFFERfor caching, inserts, and PICS requests (replaces hardcoded 500).getLicensesForPics()and added clearer progress logs to reduce memory pressure on large libraries.Written for commit be8a4b1. Summary will update on new commits.
Summary by CodeRabbit