-
Notifications
You must be signed in to change notification settings - Fork 317
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
Replace Jackson serde #10035
Replace Jackson serde #10035
Conversation
1. Avoiding loading cats. It will we loaded later anyway but `catchNonFatal` is not worth it anyway 2. Avoid copying when reading all bytes from a file to compute digest of all files
Nit: what I really like about this library is that, when it works, the context of the parsing error is pretty visible:
|
Turned out that one needs to separate definition site of the serializer from usage so that macros can do the magic properly.
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.
Please don't change dependencies of engine-common
.
When having nested option string values, decoders and encoders don't seem to match under certain conditions. Added an option to skip the values instead, which appears to remedy the problems. Moving projects around to properly setup macros.
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.
Nice startup speedup. I am just not sure what is the purpose of the new polyglot-api-macros
project. It seems to me that the single source in that project can be merged into polyglot-api-serde
project.
@@ -82,7 +85,14 @@ static final String computeDigestOfLibrarySources(List<SourceFile<TruffleFile>> | |||
try { | |||
var digest = messageDigest(); | |||
for (var source : pkgSources) { | |||
digest.update(source.file().readAllBytes()); |
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 assume this change is not related to the json serialization? I am not sure whether this computeDigestOfLibrarySources
is a useful method at all. It is used only by ImportExportCache
. And when ImportExportCache
[deserializes]
enso/engine/runtime/src/main/java/org/enso/interpreter/caches/ImportExportCache.java
Line 78 in 2ea2a57
return new CachedBindings(libraryName, bindings, Optional.empty()); |
ImportExportCache
?
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.
It's not related no. I just found out that this was taking unnecessary amount of time while profiling.
engine/polyglot-api-macros/src/main/scala/org/enso/polyglot/macros/SerdeConfig.scala
Show resolved
Hide resolved
engine/polyglot-api-macros/src/main/scala/org/enso/polyglot/macros/SerdeConfig.scala
Outdated
Show resolved
Hide resolved
@@ -1478,6 +1478,32 @@ lazy val `polyglot-api` = project | |||
.dependsOn(`logging-utils`) | |||
.dependsOn(testkit % Test) | |||
|
|||
lazy val `polyglot-api-macros` = project |
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.
What is the purpose of polyglot-api-macros
project? Do I see correctly that it contains only single source SerdeConfig.scala
? Shouldn't it be in polyglot-api-serde
?
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.
Yes, this is necessary due to jsoniter-scala
's usage of Scala macros. Macros have to be compiled separately from the usage site. Alternatively we could put everything into one module but then we would have to define some (simple) macros. I'd prefer to avoid that due to maintenance cost on our side.
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 we removing Jackson from our runtime.jar
and runner.jar
modules altogether?
@@ -1,28 +1,7 @@ | |||
package org.enso.polyglot | |||
|
|||
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo} |
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.
Removing Jackson import is good. Do we also remove the Jackson dependency?
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 did, see build.sbt
.
Pull Request Description
JSON serialization setup between Language Server and Runtime is a major contributor to startup time. This PR experiments with an alternative implementation that remedies the problem.
The new serializer uses jsoniter-scala which by some accounts claims to be really fast. In our case, more importantly, we pay negligible cost of startup setup compared to Jackson which was horribly slow.
Important Notes
Before:
![Screenshot from 2024-06-06 15-35-18](https://private-user-images.githubusercontent.com/292128/337285644-56103b82-777e-459f-966e-abdef25c2430.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS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TJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxOVQxMjEwMDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00ZjNhNDQ3NmE0YWJkNTRmZDYxOWNlMDhiODA0MzhhOWZkYjk1Yjg4MDdlNzlhMDc5OGMzMzQ5NmZjYTYzZjRmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ypOCSccEB77D-ZfBZobGfx3MnP36M8jdGjF-P8jjmEQ)
After:
Yes. About 0.8sec.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.