Replies: 0 comments 2 replies
|
I'm not going pretend I'm currently in a position to argue for or against any implications of this change in the current code base, but I'm all for your goals! :) |
0 replies
|
thanks @alexsnaps for the deep analysis, i think the answer might be simpler than you think, most of it is: "i needed these fields, i made them accessible, i moved on." and just me not being a rust guru :) you’re pointing in the right direction. let’s do it. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
If I'm reading this all correctly, and know that I'm no subject matter expert and am solely relying on the code as it is today (which might well be a foundation for future work), I'm seeing excessive
.clone()ing of conversations for reasons that I've had some difficulty seeing in the code.I think this is possibly due to the scattering of the logic across multiple places and fundamentally some lack of encapsulation.
But if I am not mistaken, the current behavior is as follow:
input,messages, andpersisted_messagesfieldsinput)Napkin math, for 1k req/s: ~35 MB/s unnecessary allocation pressure.
With regards to encapsulation, am I correct in understanding that this all works using:
ResponsesStateis a data bag with 20+ public fieldsBut these aren't requirements dictated by something I'm not currently seeing, are they?
The way I understand why the
.clone()problem exists is because there's no encapsulation:messages3x because three fields need "the same initial value" but might diverge laterIf we encapsulate state mutations behind typed methods, we can:
state.prepend_history(),state.to_backend_request())So that's the refactoring I was about to start, when I thought I probably should start a discussion around it first. What would you all think? I'd do so with these following goals in mind:
Note
I tend to try to reason about how data flows through a program. I tend to think that this particularly
well applies to a proxy btw. Beyond that, Rust tends to make these things slightly more explicit, which I
find real helpful in searching for such design improvements. Data should just be able to flow through the
the logic as unhindered as possible.
Sharing this to hopefully explain somewhat where I'm coming from and how I've been exploring the code base.
If, on the other hand, there are aspects of all this that I missed, please let me know! Whether those are current or future.
All reactions