-
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
Eliminate circe-yaml dependency #10326
Conversation
This change adds our very-own YAML parser on top of SnakeYAML. Compared to Circe parser on top of SnakeYAML. The advantage? In some not-so-distant future we might actually get rid of circe and the related performance issues. The logic is similar to what circe does i.e. analyzing SnakeYAML to build our own structure. This change is not complete, as there are still some tests failing, but most common Configs are already parseable. We _could_ auto-generate some of the code but still some of the logic would have to be tweaked by hand; the current logic has a number of special cases, as I found out the hard way.
bd01755
to
b07c1d6
Compare
Dropping circe as a decoder for Editions revealed some problems. Turns out the current implementation had even more special cases to deal with.
Replaced almost all `toYAML` locations with SnakeYAML equivalent. The encoding has to use Java collections for which there exists a built-in support. If we were to use Scala collections we would have to deal with tagging, at the very least.
In the current state of PR there is zero presence of |
Added a custom SnakeYAML Node updater to mimick the JSON -> YAML -> JSON conversion needed for updating fields. The algorithm recursively follows the key-path and inserts the desired Node. This is not a performance oriented code on purpose.
`circe-core` was marked as `provided` but no one eventually included it in the final jar, hence `NoClassFoundException`.
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 would prefer more explicit encoding/decoding. The best would be if the implementation of our SnakeYamlEncoder and Decoder would be in Java. But if this change gives us around 300 ms improvement in startup, that is good enough.
lib/scala/distribution-manager/src/main/scala/org/enso/distribution/config/GlobalConfig.scala
Outdated
Show resolved
Hide resolved
We are using SnakeYAML which is as close to Java as one can get. I understand the sentiment but YAML parsing is still used 99% of the time in Scala code. And implicits eliminate a lot of useless boilerplate code in this case. |
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.
Overall it looks like a good move forward.
Pull Request Description
This change adds our very-own YAML parser on top of SnakeYAML. Compared to Circe parser on top of SnakeYAML. The advantage? In some not-so-distant future we might actually get rid of circe and the related performance issues.
The logic is similar to what circe does i.e. analyzing SnakeYAML to build our own structure.
All configs already parseable. We could auto-generate some of the code but still some of the logic would have to be tweaked by hand; the current logic has a number of special cases, as I found out the hard way.
Closes #9113.
Important Notes
It's a bit hard to get a definite number of how things improved but here are some screenshots:
Before:
After:
There are a couple more savings in the range of 10-20ms each which all adds up easily to about 300ms.
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.