-
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
Optimize importer memory footprint #2103
Conversation
- clear bytes and items if stream file is skipped or successfully parsed Signed-off-by: Xin Li <xin.li@hedera.com>
Codecov Report
@@ Coverage Diff @@
## master #2103 +/- ##
=============================================
- Coverage 87.05% 73.87% -13.18%
+ Complexity 1744 242 -1502
=============================================
Files 315 152 -163
Lines 7731 4368 -3363
Branches 740 439 -301
=============================================
- Hits 6730 3227 -3503
- Misses 772 1085 +313
+ Partials 229 56 -173
Continue to review full report at Codecov.
|
Signed-off-by: Xin Li <xin.li@hedera.com>
But that's exactly what I stated in the call and it's what we want for balances to reduce memory usage by 66% or more. My suggestion is this: @Bean(CHANNEL_BALANCE)
MessageChannel channelBalance(BalanceParserProperties properties) {
if (properties.getQueueCapacity() <= 0) {
return MessageChannels.direct().get();
else {
return MessageChannels.queue(properties.getQueueCapacity()).get();
}
} |
Then |
Sure, RendezvousChannel might do the trick. Does it still allow 2 total files in memory? |
Yes, 2 is the best we can get. One held in downloader and one is being processed in parser. |
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.
Looking good asides MessageChannel discussion. One suggestion and thinking on if the test coverage can be expanded
@@ -225,6 +213,19 @@ private void assertFilesArchived(String... fileNames) throws Exception { | |||
.contains(fileNames); | |||
} | |||
|
|||
private void assertPostParseState(RecordFile recordFile, boolean success, |
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.
Could move this method into an abstract class for the 3 test classes to share since they are exactly the same
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.
will do. potentially can combine if not all at least most test cases for event and record. note the balance parser test is an integration test while the other two are mocked tests. perhaps I should unify the three.
...ror-importer/src/test/java/com/hedera/mirror/importer/downloader/AbstractDownloaderTest.java
Outdated
Show resolved
Hide resolved
...irror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractStreamFileParser.java
Outdated
Show resolved
Hide resolved
...irror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractStreamFileParser.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Xin Li <xin.li@hedera.com>
- refactor parser test classes Signed-off-by: Xin Li <xin.li@hedera.com>
@Bean(CHANNEL_BALANCE) | ||
MessageChannel channelBalance(BalanceParserProperties properties) { | ||
return MessageChannels.queue(properties.getQueueCapacity()).get(); | ||
return channel(properties); | ||
} | ||
|
||
@Bean(CHANNEL_EVENT) | ||
MessageChannel channelEvent(EventParserProperties properties) { | ||
return MessageChannels.queue(properties.getQueueCapacity()).get(); | ||
return channel(properties); | ||
} | ||
|
||
@Bean(CHANNEL_RECORD) | ||
MessageChannel channelRecord(RecordParserProperties properties) { | ||
return MessageChannels.queue(properties.getQueueCapacity()).get(); | ||
return channel(properties); | ||
} | ||
|
||
@Bean(INTEGRATION_FLOW_BALANCE) | ||
IntegrationFlow integrationFlowBalance(AccountBalanceFileParser parser) { | ||
return integrationFlow(parser); | ||
} | ||
|
||
@Bean(INTEGRATION_FLOW_EVENT) | ||
IntegrationFlow integrationFlowEvent(EventFileParser parser) { | ||
return integrationFlow(parser); | ||
} | ||
|
||
@Bean(INTEGRATION_FLOW_RECORD) | ||
@ConditionalOnRecordParser | ||
IntegrationFlow integrationFlowRecord(RecordFileParser parser) { | ||
return integrationFlow(parser); |
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.
have to repeat these for different beans and different names.
didn't want to move the channel bean and integration flow bean to StreamFileParser classes because I prefer separating configuration from those classes as much as I can.
} | ||
|
||
@Bean(INTEGRATION_FLOW_RECORD) | ||
@ConditionalOnRecordParser |
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.
not sure why we only have ConditionalOnRecordParser
on RecordFileParser
but not the other two parsers. anyway to avoid autowire error when parser.record.enabled
is false, I also added the annotation here
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 believe @ConditionalOnRecordParser
was added more so to help out the pubs flow which should only check whether to run when record parser is enabled.
Balance and event parser don't have a sub flow so it didn't apply.
Although I do believe we wanted to check thee annotations at some point for easier coordination.
Signed-off-by: Xin Li <xin.li@hedera.com>
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.
A debug log recommendation if anything
...rter/src/main/java/com/hedera/mirror/importer/reader/balance/CompositeBalanceFileReader.java
Outdated
Show resolved
Hide resolved
...-mirror-importer/src/main/java/com/hedera/mirror/importer/config/MessagingConfiguration.java
Outdated
Show resolved
Hide resolved
...irror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java
Outdated
Show resolved
Hide resolved
...irror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java
Show resolved
Hide resolved
...porter/src/main/java/com/hedera/mirror/importer/parser/balance/AccountBalanceFileParser.java
Outdated
Show resolved
Hide resolved
...rter/src/main/java/com/hedera/mirror/importer/reader/balance/CompositeBalanceFileReader.java
Outdated
Show resolved
Hide resolved
...mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/RecordFileParser.java
Outdated
Show resolved
Hide resolved
...a-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/event/EventFileParser.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
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
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.
One small question, but LGTM
.get(); | ||
} | ||
|
||
private MessageChannel channel(ParserProperties properties) { | ||
if (properties.getQueueCapacity() <= 0) { |
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.
If we have validation to ensure the minimum is 0, do we need to check for <
? Could just be ==
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.
Because we should write code defensively in case that other class changes in the future and it's the same number of characters either way.
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
Signed-off-by: Xin Li <xin.li@hedera.com>
708b918
SonarCloud Quality Gate failed. |
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
Detailed description:
persistBytes
to downloaderkeepFiles
to downloaderStreamFile
bytes
anditems
in post parseDirectChannel
whenqueueCapacity
<= 0Which issue(s) this PR fixes:
Fixes #2087
Special notes for your reviewer:
Checklist