Skip to content
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

feat: remove unnecessary fields from UT payload #5422

Merged
merged 4 commits into from
Jan 15, 2025
Merged

Conversation

cisse21
Copy link
Member

@cisse21 cisse21 commented Jan 10, 2025

Description

This pull request aims to enhance the efficiency of the User Transformation (UT) payload by eliminating unnecessary fields, thereby improving performance by reducing payload size.

Changes Introduced:
Field Removal: Unused or redundant fields have been identified and removed from the UT payload structure.

Screenshot 2025-01-13 at 5 21 06 PM

In the image shown above the blue line represent the latency for a User Transformation with master and the yellow line represent the latency with the changes made in this PR. This change leads to 10-15% reduction in latency

Linear Ticket

Fixes PIPE-1845

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.80%. Comparing base (e1b756b) to head (5990730).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5422      +/-   ##
==========================================
+ Coverage   74.77%   74.80%   +0.03%     
==========================================
  Files         440      440              
  Lines       61648    61668      +20     
==========================================
+ Hits        46095    46130      +35     
+ Misses      13008    13000       -8     
+ Partials     2545     2538       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cisse21 cisse21 force-pushed the feat.optimiseUTPayload branch from 7e80c9c to 4250948 Compare January 13, 2025 13:18
@cisse21 cisse21 marked this pull request as ready for review January 13, 2025 13:19
return trans.transform(ctx, clientEvents, trans.userTransformURL(), batchSize, userTransformerStage)
var dehydratedClientEvents []TransformerEvent
for _, clientEvent := range clientEvents {
dehydratedClientEvent := clientEvent.Dehydrate()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a dehydrated client in this context? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a little more in the description. Basically we send a common payload across user transformation , destination transformation and tracking plan which heavily inflates the payload size for each of them. The idea is to reduce the payload size by removing the unnecessary fields

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoever comes across this code will still have troubles understanding what Dehydrate means though, right? I don't think they'll go chasing the PR where you created this to get more context.

I suggest adding a comment here and also renaming the Dehydrate method to better reflect what it does:

  1. PruneFields
  2. StripUnnecessaryFields
  3. GetVersionsOnly
  4. ...

@lvrach
Copy link
Member

lvrach commented Jan 14, 2025

@cisse21 can you explain what's the screenshot in the description

@@ -270,7 +285,13 @@ func (trans *handle) Transform(ctx context.Context, clientEvents []TransformerEv

// UserTransform function is used to invoke user transformer API
func (trans *handle) UserTransform(ctx context.Context, clientEvents []TransformerEvent, batchSize int) Response {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kind hoping for an approach where we introduce a separate client for user transformation.

As the requirements for dt and ut further diverge, keeping them under the same implementation only adds complexity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lvrach doing that here

wanted to get this out first in the next release as this would be a quick win. WDYT?

@cisse21 cisse21 requested review from fracasula and lvrach January 14, 2025 08:58
@@ -101,6 +101,21 @@ type TransformerEvent struct {
Credentials []Credential `json:"credentials"`
}

func (e *TransformerEvent) Dehydrate() *TransformerEvent {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (e *TransformerEvent) Dehydrate() *TransformerEvent {
func (e *TransformerEvent) Dehydrate() *HydradedTransformerEvent {

Instead of using the same struct, with some fields missing, we can introduce new structs with only the fields we want to include.

This will make it easier to understand, what we plan to send and what not. Plus making the object allocation a bit lighter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it a bit difficult downstream as the transform function expected TransformerEvent. Was planning to do the same in the refactor to reduce the fields further

@cisse21 cisse21 force-pushed the feat.optimiseUTPayload branch from dea0812 to 2b7a407 Compare January 15, 2025 08:08
@cisse21 cisse21 merged commit 441f765 into master Jan 15, 2025
58 checks passed
@cisse21 cisse21 deleted the feat.optimiseUTPayload branch January 15, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants