-
Notifications
You must be signed in to change notification settings - Fork 84
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
H-3422: harpc
: rework the family of Codec
traits
#5362
Conversation
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
looking at the changes in the |
harpc
: rework the family of Codec
traits.harpc
: rework the family of Codec
traits.
harpc
: rework the family of Codec
traits.harpc
: rework the family of Codec
traits
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 think it's the right call to just rely on serde
. if we ever need/want to support other formats we can look into lift this and find a common interface, but to get things moving this is better I guess. Thank you!
I have a few comments, but mostly these are niceties/code style.
temporal-io-client = { git = "https://github.com/temporalio/sdk-core", rev = "7e3c23f" } | ||
temporal-io-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", rev = "7e3c23f" } |
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.
They are used but not as workspace dependency. Could you instead adjust @local/temporal-client
to use workspace = true
instead?
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.
see c8e5f8c
serde_plain = { version = "=1.0.2", default-features = false } | ||
serde_with = { version = "=3.11.0", default-features = false } | ||
similar-asserts = { version = "=1.6.0", default-features = false } | ||
spin = { version = "=0.9", default-features = false } |
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.
Spin is used in error-stack
but with a >=0.9
bound. Probably good to remove it, yes.
publish.workspace = true | ||
|
||
[dependencies] | ||
error-stack = { workspace = true, public = true, features = ["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.
error-stack = { workspace = true, public = true, features = ["serde"] } | |
# Public workspace dependencies | |
error-stack = { workspace = true, public = true, features = ["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.
see: 96d959c
|
||
pub trait ErrorDecoder { | ||
type Error; | ||
type Recovery; |
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 Recovery
? Do you have a quick example?
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.
see: eabf6aa
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 see, thanks!
it’s redundant
Benchmark results
|
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1
|
Flame Graph |
representative_read_entity_type
Function | Value | Mean | Flame graphs |
---|---|---|---|
get_entity_type_by_id | Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579
|
Flame Graph |
scaling_read_entity_complete_zero_depth
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 50 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 25 entities | Flame Graph | |
entity_by_id | 1 entities | Flame Graph | |
entity_by_id | 5 entities | Flame Graph |
scaling_read_entity_linkless
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 1000 entities | Flame Graph | |
entity_by_id | 100 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 10000 entities | Flame Graph | |
entity_by_id | 1 entities | Flame Graph |
representative_read_multiple_entities
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_property | depths: DT=2, PT=2, ET=2, E=2 | Flame Graph | |
entity_by_property | depths: DT=255, PT=255, ET=255, E=255 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=0, E=0 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=0, E=2 | Flame Graph | |
entity_by_property | depths: DT=0, PT=2, ET=2, E=2 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=2, PT=2, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=255, PT=255, ET=255, E=255 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=0 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=2, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=2, E=2 | Flame Graph |
scaling_read_entity_complete_one_depth
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 50 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 25 entities | Flame Graph | |
entity_by_id | 1 entities | Flame Graph | |
entity_by_id | 5 entities | Flame Graph |
🌟 What is the purpose of this PR?
This reworks the
Codec
trait, to internally useserde
, while this makesserde
a hard dependency. I think that's overall fine, as it allows us to more forward more quickly, and in any case - all of Rust is built on serde anyway.The
Encoder
andDecoder
traits haven't been removed, instead, they take a stream of items and convert them to bytes.I first tried to re-use
tokio-util
here, but found that to be quite cumbersome - especially in trait bounds, because ourCodec
ensures that only serde items are used we don't have any additional trait bound, that's not the case withtokio-util
, we'd need to write everywhere:Encoder<AccountId>
etc, which would essentially re-create the problem we already had.This is quite a large PR, simply because the
Codec
trait was pretty heavily used. The trait was previously part ofharpc-net
but has been moved intoharpc-codec
. It just felt... inappropriate to have the definition of the encoder and decoder on the network layer if it is going to be used for values on the tower layer.Errors still have their own encoder and decoder, simply because we encode two different things, errors and reports and deserialization of reports isn't possible just yet.
To proof the concept a new codec has been added:
JsonCodec
, which implements said traits and is now used throughout all tests.next steps are moving some of the types in
harpc-wire-protocol
intoharpc-codec
. Reason for this is that it feels wrong thatharpc-service
andharpc-tower
need to depend onharpc-wire-protocol
, even tho it is a completely different layer.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
turbo.json
's have been updated to reflect this