-
Notifications
You must be signed in to change notification settings - Fork 148
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
bug(#3806): Add caching in UnphiMojo #4027
base: master
Are you sure you want to change the base?
Conversation
🚀 Performance Analysis
✅ Performance gain: |
I changed names and descriptions of footprint classes, which compare |
@maxonfjvipon please, review it |
|
@maxonfjvipon I fixed build and reverted unnecessary changes, but empty string hash isn't valid for passing |
@@ -59,7 +59,7 @@ public final class FpIfTargetOlder extends FpEnvelope { | |||
* @throws IOException If fails to compare files | |||
*/ | |||
private static boolean isAfter(final Path first, final Path second) throws IOException { | |||
return Files.getLastModifiedTime(first).toInstant().isAfter( | |||
return !Files.getLastModifiedTime(first).toInstant().isBefore( |
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.
@vl4ds4m this change is unnecessary
void usesCache(@Mktmp final Path temp) throws Exception { | ||
new Saved( | ||
"{⟦std ↦ Φ.org.eolang.io.stdout, y ↦ Φ.org.eolang.x⟧}", | ||
temp.resolve("target/eo/phi/std.phi") | ||
).value(); | ||
final String hash = "123ZaRiFcHiK321"; | ||
final String hash = UnphiMojo.FAKE_HASH; |
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.
@vl4ds4m it's totally ok to slightly change the test after you introduce an implementation, let's try to use empty string here and in UnphiMojo
because it doesn't depend on tojos
@@ -335,6 +329,11 @@ void invalidatesCache(@Mktmp final Path temp) throws Exception { | |||
"{⟦std ↦ Φ.org.eolang.io.stdout, y ↦ Φ.org.eolang.x⟧}", | |||
temp.resolve("target/eo/phi/std.phi") | |||
).value(); | |||
MatcherAssert.assertThat( | |||
"The cached file's last modified timestamp should be successfully reset", | |||
cached.setLastModified(0L), |
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.
@vl4ds4m what's the reason to change this timestamp? Hard coded cached file was saved before the the original std.phi
. So it'll be anyway younger
/** | ||
* Hash directory for unphied files. | ||
*/ | ||
@SuppressWarnings("PMD.ImmutableField") | ||
@Parameter(property = "eo.hash") | ||
private String hash = ""; | ||
|
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.
Introduced a field for hash with default empty value
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.
@vl4ds4m it seems we have hash
field in several mojos now, in ProbeMojo
, in PullMojo
and in UnphiMojo
.
Let's make it only one by moving the field to the SafeMojo
and make it protected
so it'll look like:
abstract class SafeMojo {
protected CommitHash hash = new ChConstant(
new ChNarrow(new ChRemote(this.tag))
);
}
I think when it's done - it'll require some tests fixes. We're almost good to merge
MatcherAssert.assertThat( | ||
"The cached file's last modified timestamp should be strictly after the source one", | ||
cached.setLastModified(cached.lastModified() + 1), | ||
Matchers.is(true) | ||
); |
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.
Changed a cached file timpestamp, because on some platforms these files have the same timestamp and the cached file isn't considered as valid
@maxonfjvipon please, take a look |
/** | ||
* Hash directory for unphied files. | ||
*/ | ||
@SuppressWarnings("PMD.ImmutableField") | ||
@Parameter(property = "eo.hash") | ||
private String hash = ""; | ||
|
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.
@vl4ds4m it seems we have hash
field in several mojos now, in ProbeMojo
, in PullMojo
and in UnphiMojo
.
Let's make it only one by moving the field to the SafeMojo
and make it protected
so it'll look like:
abstract class SafeMojo {
protected CommitHash hash = new ChConstant(
new ChNarrow(new ChRemote(this.tag))
);
}
I think when it's done - it'll require some tests fixes. We're almost good to merge
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.
@vl4ds4m last change and we're good to merge
* If not set, will be computed from {@code tag} field. | ||
* @checkstyle VisibilityModifierCheck (5 lines) | ||
*/ | ||
protected CommitHash hash = new CommitHash.ChConstant( |
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.
@vl4ds4m let's use ChCached
(caching decorator) instead of ChConst
. This will allow not to call .value()
explicitly on the next line, in the same way it's implemented in ProbeMojo
@yegor256 please check |
Closes: #3806
This PR embeds caching in
UnphiMojo
and enables cache test cases inUnphiMojoTest
. But there is unresolved problem: these classes use irrelevant hash (FAKE_HASH
) because i can't understand how to use relevant one, so i need help to resolve it.