-
Notifications
You must be signed in to change notification settings - Fork 108
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
RecordFileLogger performing far too many queries against t_entities #550
Conversation
2bcc3fa
to
052681a
Compare
Codecov Report
@@ Coverage Diff @@
## master #550 +/- ##
=========================================
Coverage 64.27% 64.27%
Complexity 163 163
=========================================
Files 95 95
Lines 3057 3057
Branches 370 370
=========================================
Hits 1965 1965
Misses 936 936
Partials 156 156
Continue to review full report at Codecov.
|
hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/domain/EntityId.java
Outdated
Show resolved
Hide resolved
...ror-importer/src/main/java/com/hedera/mirror/importer/parser/record/EntityIdCacheLoader.java
Outdated
Show resolved
Hide resolved
...ror-importer/src/main/java/com/hedera/mirror/importer/parser/record/EntityIdCacheLoader.java
Outdated
Show resolved
Hide resolved
hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/domain/EntityId.java
Show resolved
Hide resolved
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
@CacheConfig(cacheNames = "entity_ids", cacheManager = CacheConfiguration.BIG_LRU_CACHE) | ||
public interface EntityIdRepository extends PagingAndSortingRepository<EntityId, Long> { |
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.
Once you switch to interface projection, just move these methods into existing EntityRepository
. You can't use class-level cacheconfig though, of course.
...mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/RecordFileLogger.java
Show resolved
Hide resolved
default EntityId findOrCreateBy(long entityShard, long entityRealm, long entityNum, int entityTypeId) { | ||
var found = findByNativeIds(entityShard, entityRealm, entityNum); | ||
if (!found.isPresent()) { | ||
return save(new EntityId(entityShard, entityRealm, entityNum, entityTypeId)); |
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.
Are you sure this is updating the cache? With Spring AOP you generally can't call proxied methods from inside a proxied method. It doesn't exit the class and come back in so it doesn't hit the cache decorator. You can increase spring cache logging to confirm.
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.
LGTM.
How can we test it? Maybe, if @cacheable
returns same object on cache hit, then that equality can help write a test ? and expecting different object after clearing cache (if spring data allows clearing cache)?
...ror-importer/src/main/java/com/hedera/mirror/importer/parser/record/EntityIdCacheLoader.java
Outdated
Show resolved
Hide resolved
0dce2b3
to
1e6d554
Compare
hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/config/CacheConfiguration.java
Show resolved
Hide resolved
@apeksharma To unit test the caching, we need to enable caching in the unit tests (currently off in test), fix the tests to clear out the cache in between and then we can unit test if the same object is returned. |
Performance improvement 7.92s/60k transactions |
hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/config/CacheConfiguration.java
Show resolved
Hide resolved
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.
LGTM
ded57c4
4744c43
to
ded57c4
Compare
… speed up insert. Transactions that create/update/delete entities still go through the repository causing blocking/serial queries during processing. Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
Signed-off-by: Mike Burrage <mike.burrage@hedera.com>
ded57c4
to
85f001c
Compare
Detailed description:
hedera.mirror.importer.parser.entityIdCacheSize
defaulting to 100,000. Cache does not expire. LRU.Which issue(s) this PR fixes:
Fixes #547
Fixes #533
Special notes for your reviewer:
Checklist