-
Notifications
You must be signed in to change notification settings - Fork 143
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
Do not regenerate api object that does not change #99
Conversation
Hi there! I just wanted to follow-up on this PR. Anything we can do to help with the review? Thank you! |
Thanks for you PR, sorry for the late reply as well. We'll be looking into it. |
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.
Could you just rebase your PR before I merge please?
c96a76f
to
b3740ac
Compare
b3740ac
to
1283a2a
Compare
hi @sbihel @w4ll3 - thanks for taking a look! i have rebased the commit off of upstream/main, and should be correct now. let me know if you need anything else. And also made sure tests pass locally:
|
I can't give you an exact date right now, but we have a new release planned already and this changes will be included. |
The Dynamic team is using
siwe-parser
in our codebase in production, and noticed thatParsedMessage(text)
was causing unnecessary latency in our application. When we took a closer look its implementation, we noticed that the bulk of the latency was from creating a newapgApi
:Doing this in the constructor of
ParsedMessage
is unnecessary becausenew apgApi(GRAMMAR)
would never actually change and thatGRAMMAR
is a staticconst
declared earlier in the file. This means every time we instantiate theParsedMessage
class, we generate a new and unnecessaryapgApi
.This PR removes the expensive API generation from
ParsedMessage
's constructor and make sure we only generate the API once.siwe-parser
's tests have a bunch of test cases they evaluate against to check that the parser works. Locally, I added basic time duration that looks like:Here are the results collected from running the test BEFORE I made the change (this was running on a M1 Max):
And here are the results collected after the change was made:
As you can see, the duration for instantiating the
ParsedMessage
class goes down significantly after the change - and this would translate to much lower latency in our application and the endpoint that uses this.