Open
Conversation
Contributor
|
Thank you Lukas! I'll study this and get back you you on these questions. Agreed that we need to address the performance regression for sure. |
Contributor
Author
|
I was able to address the performance regressions by manually implementing @smunini regarding reviewing this, it probably does not make much sense to go through each commits individually. You should focus on the final state. |
Contributor
|
Thank you Lukas! I should be able to review this PR in the next day or so. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Steve,
this PR implements full XML support (R4, R4B, R5 and R6 finally roundtrip successfully after a lot of back and forth).
XML vs JSON model
While most of the mediation between the XML and JSON models is handled by dedicated XML serializer and deserializer, I had to make a few changes to the derive macros. This is mostly to reduce some complexity and the need for extensive buffering and reordering of primitive id and extension. Otherwise one would have to translate e.g.
brithDate(XML) tobirthDate,_birthDate(JSON) model, just to have the derived Deserialize impl convert it back to the nestedbirthDate(sturct) element.The
TmpXxxstructs now use to helper enums in theDeserializeimpls:PrimitiveOrElementto be able to handle both thebirthDate,_birthDate(JSON) andbrithDate(XML) natively.SingleOrVecfor sequence fields. This is required because the XML deserializer does not have extensive knowledge of the FHIR model and can thus not know if it needs to callvisit_seqorvisit_xxx(for single-cardinality fields).A potential drawback of this approach, is that the deserializer is more lenient for some invalid JSON inputs. E.g.
”birthDate”: { “value”: “..”, “id”: “..”, “extension”: {..}}although invalid FHIR JSON.Similar for passing single values where a sequence would be expected.
In my opinion this trade off is acceptable, given the extensive discussion about worse tradeoffs we had in #20.
But, please let me know what you think!
JSON Benchmark (no regression)
Unfortunately the above mentioned changes resulted in some significant performance regressions.I will try to investigate and improve on this, but I wanted to share the current state with you.
The current implementation shows almost no regression.
Initially I removed a bunch of JSON skips, that actually seem to work properly.
One of the later commits re-added them to make the numbers across branches comparable. Do you want to keep these skips or shall we drop the commit that reintroduces them again?
serde-supportI added a new helper crate
serde-supportto hold the newPrimitiveOrElementandSingleOrVechelpers.I also moved the preexisting
IdAndExtensionHelpersthere, which were previously generated as nested structs all over again for each individual FHIR struct.This improves the compile time somewhat (almost negligible in my local tests) but the final binary size signficicantly (
test_examplesbinary from > 2GB after addingPrimitiveOrElementandSingleOrVecto 1,23GB; with debug symbols though).We can think about moving the helpers into a private mod within
crate/fhir/src. This would require moving[test_json_serde.rs](http://test_json_serde.rs/)and[test_xml_serde.rs](http://test_xml_serde.rs/)intocrate/fhir/srcthough as these need access to the helpers.Interestingly even with having
[test_json_serde.rs](http://test_json_serde.rs/)and[test_xml_serde.rs](http://test_xml_serde.rs/)incrate/fhir/test, they can still not access private identifiers fromcrate/fhir/src.Let me know which approach you prefer:
serde-support(current state, my 1st choice): Separation of src and tests (in helios-serde); but additional crate not intended for public useserde_supportpackage inhelios-fhir (my last choice): Noisy public API forhelios-fhir`serde_supportpackage inhelios-fhir (my 2nd choice):test_json_serde.rsandtest_xml_serde.rsneed to be moved into thecrates/fhir/src` tree; tests are less separated by concernLeft Todo
Potential future improvements
To the derive macro
serde_json::Value