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

Open
#369 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

Start by locating the addFact method and the debug(...) call shown in the issue, then inspect how debugging is configured elsewhere in the package. Determine how production can disable this logging and verify the addFact path with debugging both enabled and disabled; done means avoiding the reported overhead without removing useful debug output.

Written by the indexing model from the issue text.

Description

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 😄

Dominant language
JavaScript
Stars
3.1k
Forks
507
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CacheControl/json-rules-engine

All issues in CacheControl/json-rules-engine

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.