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

Decreased Performance due to 'debug(...)' statements in production #369

Open
Gi-jutsu opened this issue Jul 11, 2024 · 2 comments
Open

Decreased Performance due to 'debug(...)' statements in production #369

Gi-jutsu opened this issue Jul 11, 2024 · 2 comments

Comments

@Gi-jutsu
Copy link

Gi-jutsu commented Jul 11, 2024

Hi @CacheControl
Hope your doing well 😄
First I'd like to thank you for the work done, this is a really useful package !

I'd like to point out a performance issue we are facing in production, there's a debug statement that is run while the addFact function is executed which cause a 2 seconds delay

  addFact (id, valueOrMethod, options) {
    let factId = id
    let fact
    if (id instanceof Fact) {
      factId = id.id
      fact = id
    } else {
      fact = new Fact(id, valueOrMethod, options)
    }
    debug(`engine::addFact id:${factId}`) // <--- This one
    this.facts.set(factId, fact)
    return this
  }

Here's our CPU Profiling

Screenshot 2024-07-11 at 11 40 17

Is there a way to disable the debug statements ? Otherwise it could be nice to add an option to disable them
Thanks !

If you would like, I would be glad to open a PR to address the following issue.

Have a nice day 😄

@chris-pardy
Copy link
Collaborator

HI @Gi-jutsu Thanks for raising the issue.
The current code in the debug function checks environment variables or local storage to enable debug statements here Could you confirm if you have debugging enabled and what environment you're running and profiling your code in.

If the issue is the time it takes to check if the debugging statements should be enabled there are likely some optimizations that could be made to speed up the runtime of the debugging statements.

@Gi-jutsu
Copy link
Author

Gi-jutsu commented Jul 12, 2024

Hello 😄
Thanks for your response,

I don't think debugging is enabled
We didn't set the DEBUG key in our environments ( perhaps GCP is adding it afterwards I'm not sure about that )

I'm running a NestJS application in GCP Compute Engine through a Compute Instange Group ( Dockerized )
For the Profiling I'm using Google Cloud Profiler ( see: https://www.npmjs.com/package/@google-cloud/profiler )

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