parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.86k stars 4.78k forks source link

[perf] Consider skipping input/result serialization on Cloud Code triggers when loglevel is silent #9148

Closed mdarens closed 3 months ago

mdarens commented 3 months ago

Issue Description

Currently, registering any trigger will stringify input/results and call the associated logTrigger* utilities, which internally do an early return after checking logLevel, which is passed in as a param based on config.logLevels.triggerAfter, config.logLevels.triggerBeforeSuccess etc. The given log utility will then early return or truncate the stringified value, but if we know the loglevel from the caller we can avoid the serialization overhead altogether.

Steps to reproduce

  1. Set logLevels.triggerAfter to silent
  2. Register any Cloud Code hook eg afterFind
  3. Trigger the hook and attach to the Parse Server process

Actual Outcome

In triggers.js, the result is stringified before being discarded inside the logger function

Expected Outcome

It'd be nice to avoid serializing objects we don't intend to log

Environment

v7.1.0-alpha.9

Server

Database

Client

Logs

parse-github-assistant[bot] commented 3 months ago

Thanks for opening this issue!

dplewis commented 3 months ago

I believe this feature has already been added https://github.com/parse-community/parse-server/pull/8803.

mdarens commented 3 months ago

Whoops, my mistake! I was looking at what appeared to be the latest tagged release. Thanks!