Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

chore(core): store cls contexts on a Map #786

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

mmarchini
Copy link
Contributor

Node.js v12 is affected by a V8 regression where many
insert/deletes on a POJO will trigger an undefined state on V8, leading
to a huge performance regression which can cause each insert/delete
operations on that object to take hundreds of times more. The Map
structure is not affected by this performance regression (and is
recommended by engine developers to deal with large key/value stores).

Contexts on cls-ah are stored on a POJO, and since inserts/deletes
happen often (they are triggered by async_hooks on init and destroy),
applications with high RPS or with high amount of async operations will
hit the threshold, turning the regression on and leading to a huge
performance overhead on each new async operation. Changing to a Map will
avoid that issue.

Ref: nodejs/node#31961

Node.js v12 is affected by a V8 regression where many
insert/deletes on a POJO will trigger an undefined state on V8, leading
to a huge performance regression which can cause each insert/delete
operations on that object to take hundreds of times more. The Map
structure is not affected by this performance regression (and is
recommended by engine developers to deal with large key/value stores).

Contexts on cls-ah are stored on a POJO, and since inserts/deletes
happen often (they are triggered by async_hooks on init and destroy),
applications with high RPS or with high amount of async operations will
hit the threshold, turning the regression on and leading to a huge
performance overhead on each new async operation. Changing to a Map will
avoid that issue.

Ref: nodejs/node#31961
@codecov-io
Copy link

codecov-io commented Mar 27, 2020

Codecov Report

Merging #786 into master will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #786      +/-   ##
==========================================
+ Coverage   95.25%   95.37%   +0.12%     
==========================================
  Files         148      148              
  Lines       10447    10655     +208     
  Branches      794      805      +11     
==========================================
+ Hits         9951    10162     +211     
+ Misses        496      493       -3     
Impacted Files Coverage Δ
src/tracecontext-format.ts 95.74% <0.00%> (-1.76%) ⬇️
test/test-tracecontext-format.ts 96.62% <0.00%> (-0.78%) ⬇️
test/test-prometheus-stats.ts 100.00% <0.00%> (ø)
test/test-stackdriver-monitoring-utils.ts 100.00% <0.00%> (ø)
src/internal/cls-ah.ts 55.22% <0.00%> (+0.67%) ⬆️
test/test-stackdriver-cloudtrace.ts 100.00% <0.00%> (+4.34%) ⬆️
src/common-utils.ts 100.00% <0.00%> (+36.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 754b904...42a4b7a. Read the comment docs.

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the PR.

@mayurkale22 mayurkale22 merged commit 18b5cfb into census-instrumentation:master Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants