-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main | Performance improvements #3586
Open
dubdabasoduba
wants to merge
134
commits into
main
Choose a base branch
from
performance-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
134 commits
Select commit
Hold shift + click to select a range
deb1cfd
Test single transaction save for questionnaires
LZRS 8129afd
Caching questionnaires and their SM
aurangzaibumer e9221d1
spotless ran
aurangzaibumer 22a908f
Fetch search results in batches for when loading all
LZRS 5022fa8
Fix infinite loop for mocks with FhirEngine#search in tests
LZRS 6ee690d
[WIP] FhirEngine search integration tests
LZRS ae166a4
spotless ran
aurangzaibumer 79f664d
updated tests
aurangzaibumer 76a4113
Merge branch 'main' into caching_resources
aurangzaibumer a06ca8c
Merge branch 'main' into caching_resources
dubdabasoduba c6be824
WIP tests updated
aurangzaibumer 3e307d5
Merge remote-tracking branch 'origin/caching_resources' into caching_…
aurangzaibumer 2390a89
Merge branch 'main' into caching_resources
aurangzaibumer 0381c5a
resolved feedback
aurangzaibumer 45e135f
spotess ran
aurangzaibumer 0171ca2
Merge branch 'main' into caching_resources
aurangzaibumer 266dd65
Upgrade FHIR SDK depenencies ⬆️
ndegwamartin 6522d71
Upragde SDC library
ndegwamartin 241e03e
Replace JWT token parser library
ndegwamartin acf6d23
Fix CQL Content Test
ndegwamartin b6b45ff
Fix unit tests ✅
ndegwamartin 8638f22
Refactor to remove Dispatch Provider
ndegwamartin da63a1b
Fix unit test ✅
ndegwamartin a520fea
Refactor Knowledge Manager Resources Persistance
ndegwamartin 7eb0fde
Refactor CQL Content tests
ndegwamartin 0ad5ada
Fix AppSettingModel unit tests ✅
ndegwamartin 783be6d
Refactor Cancel previous worflow to use native commands
ndegwamartin 24c5b2d
Upgrade CI API level to 34
ndegwamartin 5074794
Clean up Translations
ndegwamartin 54b08f7
Fix measure reporting
ndegwamartin c01d519
Fix Workflow Configuration
ndegwamartin 8400b5f
Fix QuestionnaireViewModel unit tests ✅
ndegwamartin b6770ed
Clean up WorkManager after running unit tests
ndegwamartin 172819a
Remove skyscreamer test dependency
ndegwamartin e5ee043
Fix build 💚
ndegwamartin 5746a3c
Clean up gradle dependencies configuration
ndegwamartin aecff74
Move measure reporting evaluation to BG thread
ndegwamartin d2cdd22
Fix MeasureReportRepositoryTest
ndegwamartin 1107d30
Fix MeasureReportRepositoryTest
ndegwamartin b8f213d
Fix MeasureReportViewModel unit tests ✅
ndegwamartin d95173f
Fix Measure Reporting
ndegwamartin 638fd57
Merge remote-tracking branch 'origin/main' into performance-improvements
LZRS 2806bdc
Merge remote-tracking branch 'origin/migrate-deps' into performance-i…
LZRS 22e3ce3
Migrate Engine and Workflow libraries
ndegwamartin 3953377
Merge remote-tracking branch 'origin/migrate-deps' into performance-i…
LZRS 9027b74
Merge remote-tracking branch 'origin/caching_resources' into performa…
LZRS 6756c08
Merge remote-tracking branch 'origin/test_save_with_transaction' into…
LZRS 96dd00e
Refactor register filter with REL tags
ellykits 055a1be
Update default pageSize to 15
ellykits 960176c
Fix loading locations on map
ellykits c13157c
Refactor data structure used on base resource search results
ellykits 06d81a9
Merge branch 'main' into fix-register-filters
dubdabasoduba 3f4c49e
Merge branch 'fix-register-filters' of github.com:opensrp/fhircore in…
ellykits 566b65d
Process saveCredentials in the background
qiarie 6c32e62
Refactor code
ellykits 6ffbca0
Delete unnecessary code
ellykits 3eeb9aa
Refactor retrieving related resources
ellykits fb0a037
Merge branch 'main' into fix-register-filters
ellykits 94c13ff
Optimize data structures and perform parallel processing
ellykits 20980f7
Use recent version of rules engine library
ellykits b01b59c
Refactor implementation for decoding image resources to bitmap
ellykits b232cce
Fix related resource count on register
ellykits 398c987
Fix loading related resources
ellykits aca51d7
Batch related resource queries
ellykits 2e3e48c
Map resources to RepositoryResourceData with async map
ellykits 2eb9c85
Make infinite scroll the default register behavior
ellykits b3f838a
Disable automatic intialization of emoji2
ellykits 77d1662
Run spotlessApply
ellykits 513c805
Update tests for displaying images (#3506)
Lentumunai-Mark 8546693
Refactor navigation to GeowidgetLauncher workflow
ellykits ba00c5e
Merge remote-tracking branch 'origin/refactor-login-save-credentials'…
LZRS 81e8b7d
Use dipatcher IO to handle questionnaire submission
LZRS 383be26
Merge remote-tracking branch 'origin/fix-register-filters' into perfo…
LZRS 639195f
Merge remote-tracking branch 'origin/handle-submission-perf-improveme…
LZRS bd68521
Hotfix space_asterisk
LZRS 61a2abb
Upgrade engine to v1.0.0-preview14.1-SNAPSHOT
LZRS 27c5f64
Update infiniteScroll to not be default
qiarie 39c1db6
Update sdk versions
LZRS aad8b61
Update integration Faker to fix error
LZRS ef67328
Revert upgrade on workflow and knowledge libs
LZRS c04024f
Upgrade FHIR SDK depenencies ⬆️
ndegwamartin e2da55e
Upragde SDC library
ndegwamartin f6bbada
Replace JWT token parser library
ndegwamartin 64c6297
Fix CQL Content Test
ndegwamartin 7e616ac
Fix unit tests ✅
ndegwamartin 4f3c74c
Refactor to remove Dispatch Provider
ndegwamartin 6d35db9
Fix unit test ✅
ndegwamartin 21420ae
Refactor Knowledge Manager Resources Persistance
ndegwamartin 6920620
Refactor CQL Content tests
ndegwamartin fdc9097
Fix AppSettingModel unit tests ✅
ndegwamartin ed1dee7
Refactor Cancel previous worflow to use native commands
ndegwamartin 35f22b4
Upgrade CI API level to 34
ndegwamartin 9d83a1d
Clean up Translations
ndegwamartin 8aa5740
Fix measure reporting
ndegwamartin 5074b5a
Fix Workflow Configuration
ndegwamartin e603cda
Fix QuestionnaireViewModel unit tests ✅
ndegwamartin 25df56e
Clean up WorkManager after running unit tests
ndegwamartin 9b9f922
Remove skyscreamer test dependency
ndegwamartin 2cfe37c
Fix build 💚
ndegwamartin ff1e3c6
Clean up gradle dependencies configuration
ndegwamartin 9a96a82
Move measure reporting evaluation to BG thread
ndegwamartin 8ff7951
Fix MeasureReportRepositoryTest
ndegwamartin 6c56419
Fix MeasureReportRepositoryTest
ndegwamartin 4057e11
Fix MeasureReportViewModel unit tests ✅
ndegwamartin 74f754d
Fix Measure Reporting
ndegwamartin 5e6b203
Migrate Engine and Workflow libraries
ndegwamartin a1ef8cd
Update Workflow library
ndegwamartin ae6708d
Fix evaluate Population Measure
ndegwamartin afb4ade
Update SDC snapshot to 14.1
ndegwamartin 3d7b2e2
Remove unrecommended forced portrait format
ndegwamartin affa880
Refactor from using deprecated KnowledgeManager methods loadResources
ndegwamartin 37a462b
Clean up TOML catalog file
ndegwamartin d3250b2
Revert Knowledge Manager and Workflow Library Upgrades
ndegwamartin 9774be9
Display symbol instead of unicode
FikriMilano c9d2bde
Refactor usage of FHIR JSONParser to support concurrency
ndegwamartin d2ffbb5
Update FHIR SDK library versions
ndegwamartin 234c7d6
Geowidget configuration
ndegwamartin 0a72665
Fix build 💚
ndegwamartin 7f4da95
SDK Engine to RC3
ndegwamartin f694d0b
Fix build
ndegwamartin e019834
Merge remote-tracking branch 'origin/migrate-deps' into performance-i…
LZRS 82aa807
Merge remote-tracking branch 'origin/migrate-deps' into performance-i…
LZRS 8ad1cbd
Fix failing ci tests
LZRS 7c51716
Update data-capture lib to v1.1.0-preview14-rc2-SNAPSHOT
LZRS 441e792
Merge remote-tracking branch 'origin/main' into performance-improvements
LZRS ba76e1f
Merge branch 'main' into performance-improvements
dubdabasoduba 2eb0b8c
Fix errors in tests
LZRS 692380d
🐛 Readd the eusm mg and bi flavour
dubdabasoduba 6993289
🔥 Remove unnecessary files
dubdabasoduba bd7b3a5
Merge remote-tracking branch 'refs/remotes/origin/performance-improve…
dubdabasoduba b888647
🍻 Removing double flavour defination
dubdabasoduba 2b46335
Fix failing QuestionnaireViewModel tests
LZRS 776033b
Merge branch 'main' into performance-improvements
qiarie 331ec24
Merge branch 'main' into performance-improvements
dubdabasoduba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
47 changes: 47 additions & 0 deletions
47
android/engine/src/main/java/org/smartregister/fhircore/engine/datastore/ContentCache.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.datastore | ||
|
||
import androidx.collection.LruCache | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import org.hl7.fhir.r4.model.Resource | ||
import timber.log.Timber | ||
|
||
object ContentCache { | ||
private val maxMemory: Int = (Runtime.getRuntime().maxMemory() / 1024).toInt() | ||
private val cacheSize: Int = maxMemory / 8 | ||
private val cache = LruCache<String, Resource>(cacheSize) | ||
|
||
@JvmStatic | ||
suspend fun saveResource(resourceId: String, resource: Resource) = | ||
withContext(Dispatchers.IO) { | ||
cache.put("${resource::class.simpleName}/$resourceId", resource) | ||
Timber.i("ContentCache:saveResource: $resourceId") | ||
} | ||
|
||
@JvmStatic | ||
fun getResource(resourceId: String): Resource? { | ||
return cache[resourceId]?.also { Timber.i("ContentCache:getResource: $resourceId") } | ||
} | ||
|
||
suspend fun invalidate() = | ||
withContext(Dispatchers.IO) { | ||
cache.evictAll() | ||
Timber.i("ContentCache: clearing cache") | ||
Check warning on line 45 in android/engine/src/main/java/org/smartregister/fhircore/engine/datastore/ContentCache.kt Codecov / codecov/patchandroid/engine/src/main/java/org/smartregister/fhircore/engine/datastore/ContentCache.kt#L44-L45
|
||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we introducing this cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is this Kotlin library https://github.com/MayakaApps/Kache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ellykits I think part of this PR has content from #3461. Maybe we can make the switch there cc: @ndegwamartin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename that class, it is more of a CacheHelper, the actual cache it android native -
androidx.collection.LruCache