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

Expensive instantiation of Errors to capture stack traces? #290

Closed
leiffoged opened this issue Mar 26, 2022 · 1 comment
Closed

Expensive instantiation of Errors to capture stack traces? #290

leiffoged opened this issue Mar 26, 2022 · 1 comment

Comments

@leiffoged
Copy link

First of all, very thrilled that this library exists. I saw this on hacker news the other day and benchmarked it against the library I currently use and it's loads faster. Excellent, so I'm moving over.

For a number of reasons, I'm not able to migrate most of the queries in the code base right away, so I'm utilizing sql.unsafe to unblock these queries for now (for a number of reasons, I can't use prepared statements in these places). However, every unsafe query instantiates a new Error object to capture the stack trace at the point of query creation, which is quite expensive.

This is the line that's dominating CPU usage (over half of query-related CPU usage):

? new Error()

Is there a way I could disable this functionality? Thanks for your input and appreciate the hard work as making such an awesome library.

@porsager
Copy link
Owner

Ah yes, I guess my hunch was correct here: #273 (comment)

I'll make a new release that only creates errors for stack trace in unsafe if debug: true.

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

No branches or pull requests

2 participants