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

Make tcencode more performant by avoiding json roundtrip conversion #446

Closed

Conversation

patmmccann
Copy link

fixes #444

@patmmccann patmmccann changed the title Update GVL.ts Make tcencode more performant by avoiding json roundtrip conversion Apr 25, 2024
@morinel
Copy link

morinel commented Apr 25, 2024

Thank you, a N=1 preliminary test shows this already greatly improves performance, reducing the time to encode the string from 75ms to 15ms. If the cloning of the GVL could be done only once, this would once again halve the time spent, to maybe 8ms.

stacks,
dataCategories,
vendors: fullVendorList
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a deep clone of VendorList, right? We will return references to objects like vendors and anyone outside of the library could update it, maybe it's not good.

The JSON.parse(JSON.stringify()) is ugly and very slow particular for the very big object like GVL. Maybe we can develop an alternative solution creating custom deep clone method in this case as we know the GVL structure?

@sevriugin
Copy link
Collaborator

There is PR for GVL clone avoiding JSON.parse(JSON.stringify())

@HeinzBaumann
Copy link
Collaborator

I suggest we close this PR in favor of #447

@sevriugin
Copy link
Collaborator

I have tested the new clone vs old one and it works 40% faster:
new: 0,340041995048523
old: 0,545000076293945
we can think about more performance improvements but as the the first step it's good enough

@patmmccann
Copy link
Author

@HeinzBaumann agreed

@patmmccann patmmccann closed this Apr 29, 2024
@patmmccann patmmccann deleted the patch-1 branch April 29, 2024 18:54
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.

TCString.encode is very slow
4 participants