-
Notifications
You must be signed in to change notification settings - Fork 15
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
MOB462 Expose marginUsage from isolated positions #322
Conversation
@@ -400,6 +406,7 @@ data class SubaccountPosition( | |||
existing.resources !== resources || | |||
existing.childSubaccountNumber !== childSubaccountNumber || | |||
existing.freeCollateral !== freeCollateral || | |||
existing.marginUsage !== marginUsage || |
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.
Why are we using referential equality here?
Also taking a step back, what is the goal of this if block? Why does returning existing vs a new object matter? Do we need to check fields one by one? Why not just construct the object and use built-in data class equality?
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.
You are right, childSubaccountNumber is not an object so shouldn't be referential equality. Changed.
All others are objects.
Those output objects can be larger hierarchal objects. Creating data object from IMap will be slower since it is not just a single object being created. It is important for abacus to be as fast as possible as we are dealing with three platforms.
When existing object (which enables referential equality) is returned, downstream code uses referential equality to check if additional code gets triggered. Again, this gives us much better performance than returning a data object even if there is no change.
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, i'm curious if this architecture was adopted in response to actual perf problems or if it's more theoretical? it is not a common pattern and sort of fragile with new devs onboarding, i could easily see someone accidentally creating new objects instead of checking against existing.
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.
approving for now to unblock, but do think this is worth discussing more
Simple PR: Design shows the margin usage changes for the isolated position. That needs to be exposed in object.