Skip to content
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

track cache usage #69

Merged
merged 2 commits into from
Dec 16, 2024
Merged

track cache usage #69

merged 2 commits into from
Dec 16, 2024

Conversation

SrdjanStevanetic
Copy link
Contributor

No description provided.

@@ -263,7 +263,7 @@ void translationPangeanicNoSrcMultipleLanguages() throws Exception {
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.content(requestJson))
.andExpect(status().isOk())
// .andExpect(status().isOk())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why this was commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, it works fine.

@@ -39,7 +39,7 @@
public abstract class BaseTranslationTest extends IntegrationTestUtils {

protected MockMvc mockMvc;
protected final static int redisPort=6370;
protected final static int redisPort=16370;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add redis test container to integration tests within the scope of this ticket (similar to mongo container is set api) https://testcontainers.com/modules/redis/

if(isCachingEnabled()) {
//save result in the redis cache
redisCacheService.store(toTranslate);
//logging the number of translated/cached lines and chars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the logging part to own method and use a java object to collect the metrics, e.g. TranslationCashingStats.

int numCharsCached=translationObjs.stream().filter(el -> el.isRetrievedFromCache()).map(el -> el.getTranslation().length()).reduce(0, Integer::sum);
int numLinesTranslated=toTranslate.size();
int numCharsTranslated=toTranslate.stream().map(el -> el.getText().length()).reduce(0, Integer::sum);
if(logger.isInfoEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the metrics are not logs, their computation is redundand, please update acordingly.

int numLinesCached=(int) translationObjs.stream().filter(el -> el.isRetrievedFromCache()).count();
int numCharsCached=translationObjs.stream().filter(el -> el.isRetrievedFromCache()).map(el -> el.getTranslation().length()).reduce(0, Integer::sum);
int numLinesTranslated=toTranslate.size();
int numCharsTranslated=toTranslate.stream().map(el -> el.getText().length()).reduce(0, Integer::sum);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorectly computed, as it must not include the texts discarded for translation (i.e. nonTranslatable & same language)

redisCacheService.store(toTranslate);
//logging the number of translated/cached lines and chars
int numLinesCached=(int) translationObjs.stream().filter(el -> el.isRetrievedFromCache()).count();
int numCharsCached=translationObjs.stream().filter(el -> el.isRetrievedFromCache()).map(el -> el.getTranslation().length()).reduce(0, Integer::sum);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for performance reasons it is better to use a regular for loop, in which both the lines and the chars are computed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the computation of the lines and chars server by the translation service must be computed as well,
see last row in the comment: https://europeana.atlassian.net/browse/EA-3969?focusedCommentId=133237

@gsergiu gsergiu merged commit f5e8368 into develop Dec 16, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants