-
Notifications
You must be signed in to change notification settings - Fork 323
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
Pre compute suggestion db during build time #5698
Changes from 1 commit
b95a302
6bb4d43
9c84027
b84603e
1ee00d3
e2ac361
d62ec42
560a107
b68da75
8f7314e
2fbdf75
f413b62
958cc78
1ff4c25
ce821b1
5bff1ab
f480e03
335305a
b4a98a4
6638c9d
283b6f5
9081707
0e769c1
6a96e38
77c5a2b
009b595
31773a6
a45898a
5314e10
1447ed0
20c2e40
89739c0
36862c6
3468399
952f0f6
4742f5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ protected Optional<Metadata> metadataFromBytes(byte[] bytes) { | |
@Override | ||
protected Optional<String> computeDigest(CachedSuggestions entry, TruffleLogger logger) { | ||
var digest = messageDigest(); | ||
entry.getSuggestions().getSuggestions().forEach(suggestion -> { | ||
entry.getSuggestions().forEach(suggestion -> { | ||
ByteBuffer bytes = ByteBuffer.allocate(Integer.BYTES).putInt(suggestion.hashCode()); | ||
digest.update(bytes); | ||
}); | ||
|
@@ -107,7 +107,7 @@ protected Optional<Roots> getCacheRoots(EnsoContext context) { | |
|
||
@Override | ||
protected Object extractObjectToSerialize(CachedSuggestions entry) { | ||
return entry.getSuggestions(); | ||
return entry.getSuggestionsObjectToSerialize(); | ||
} | ||
|
||
// Suggestions class is not a record because of a Frgaal bug leading to invalid compilation error. | ||
|
@@ -125,7 +125,7 @@ public List<Suggestion> getSuggestions() { | |
} | ||
|
||
// CachedSuggestions class is not a record because of a Frgaal bug leading to invalid compilation error. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the error? Maybe updating to new version of frgaal would fix the problem. If I modify: enso$ git diff
diff --git engine/runtime/src/main/java/org/enso/compiler/SuggestionsCache.java engine/runtime/src/main/java/org/enso/compiler/SuggestionsCache.java
index f5d65b8e0..220c01e9c 100644
--- engine/runtime/src/main/java/org/enso/compiler/SuggestionsCache.java
+++ engine/runtime/src/main/java/org/enso/compiler/SuggestionsCache.java
@@ -125,16 +125,7 @@ public final class SuggestionsCache
}
// CachedSuggestions class is not a record because of a Frgaal bug leading to invalid compilation error.
- public final static class CachedSuggestions {
-
- private final LibraryName libraryName;
- private final Suggestions suggestions;
-
- public CachedSuggestions(LibraryName libraryName, Suggestions suggestions) {
- this.libraryName = libraryName;
- this.suggestions = suggestions;
- }
-
+ public record CachedSuggestions(LibraryName libraryName, Suggestions suggestions) {
public LibraryName getLibraryName() {
return libraryName;
}
I am seeing:
That's a wild error. Reported to the frgaal project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is what I was seeing as well and the reason why in other cases I don't use the record. Thanks for reporting it with frgaal |
||
final static class CachedSuggestions { | ||
public final static class CachedSuggestions { | ||
|
||
private final LibraryName libraryName; | ||
private final Suggestions suggestions; | ||
|
@@ -139,9 +139,13 @@ public LibraryName getLibraryName() { | |
return libraryName; | ||
} | ||
|
||
public Suggestions getSuggestions() { | ||
public Suggestions getSuggestionsObjectToSerialize() { | ||
return suggestions; | ||
} | ||
|
||
public List<Suggestion> getSuggestions() { | ||
return suggestions.getSuggestions(); | ||
} | ||
} | ||
|
||
record Metadata( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,14 +115,21 @@ object NotificationHandler { | |
libraryName: LibraryName, | ||
libraryVersion: LibraryVersion, | ||
location: Path | ||
): Unit = sendMessage( | ||
Api.LibraryLoaded( | ||
namespace = libraryName.namespace, | ||
name = libraryName.name, | ||
version = libraryVersion.toString, | ||
location = location.toFile | ||
): Unit = { | ||
sendMessage( | ||
Api.LibraryLoaded( | ||
namespace = libraryName.namespace, | ||
name = libraryName.name, | ||
version = libraryVersion.toString, | ||
location = location.toFile | ||
) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that the |
||
) | ||
endpoint.sendToSelf( | ||
Api.Request( | ||
Api.DeserializeLibrarySuggestions(libraryName) | ||
) | ||
) | ||
} | ||
|
||
/** @inheritdoc */ | ||
override def trackProgress(message: String, task: TaskProgress[_]): Unit = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.enso.interpreter.instrument.command | ||
|
||
import org.enso.interpreter.instrument.execution.RuntimeContext | ||
import org.enso.interpreter.instrument.job.DeserializeLibrarySuggestionsJob | ||
import org.enso.polyglot.runtime.Runtime.Api | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
/** A command that initiates the deserialization of suggestions. | ||
* | ||
* @param maybeRequestId an option with request id | ||
*/ | ||
class DeserializeLibrarySuggestionsCmd( | ||
maybeRequestId: Option[Api.RequestId], | ||
request: Api.DeserializeLibrarySuggestions | ||
) extends Command(maybeRequestId) { | ||
|
||
/** @inheritdoc */ | ||
override def execute(implicit | ||
ctx: RuntimeContext, | ||
ec: ExecutionContext | ||
): Future[Unit] = | ||
ctx.jobProcessor.run( | ||
new DeserializeLibrarySuggestionsJob(request.libraryName) | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.enso.interpreter.instrument.job | ||
|
||
import org.enso.editions.LibraryName | ||
import org.enso.interpreter.instrument.execution.RuntimeContext | ||
import org.enso.polyglot.runtime.Runtime.Api | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
/** A job responsible for deserializing suggestions of loaded library. | ||
* | ||
* @param libraryName the name of loaded library | ||
*/ | ||
final class DeserializeLibrarySuggestionsJob( | ||
libraryName: LibraryName | ||
) extends Job[Unit]( | ||
List(), | ||
isCancellable = false, | ||
mayInterruptIfRunning = false | ||
) { | ||
|
||
/** @inheritdoc */ | ||
override def run(implicit ctx: RuntimeContext): Unit = { | ||
val serializationManager = | ||
ctx.executionService.getContext.getCompiler.getSerializationManager | ||
serializationManager | ||
.deserializeSuggestions(libraryName) | ||
.foreach { cachedSuggestions => | ||
ctx.endpoint.sendToClient( | ||
Api.Response( | ||
Api.SuggestionsDatabaseSuggestionsLoadedNotification( | ||
cachedSuggestions.getSuggestions.asScala.toVector | ||
) | ||
) | ||
) | ||
} | ||
} | ||
} |
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.
can be moved to the condition with the log using it?