Performance of this deep equal implementation is generally proportionally between 5x slower and 700x slower compared to native deepStrictEqual

オープン
#109 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, node.js
領域
performance

調査の方向性

src/tests/self.ts の 324-386 行付近にあるベンチマークから始め、ネイティブの deepStrictEqual との比較を再現してください。報告されている配列およびオブジェクトのケースに対して deep-equal の実装をプロファイルし、その後、同じベンチマークでパフォーマンスの変化を検証し、正しさに変化がないことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

I have a test implemented here using my test/benchmark library. I've also taken the plot that this generates and hosted it publicly on the net here: https://unphased.github.io/static-sharing/2024-03-29/deepequal_perf/deepequal_perf_collisions.html

I like this method of sharing benchmark results in HTML format since the plot made with uplot allows for interacting with series and zooming in.

The general summary based on the above plotting is that although this deep-equal implementation does not have an asymptotic algorithmic shortcoming compared to the builtin (as demonstrated by the straight lines in the first plot), it is consistently between 5x slower (if I compare large arrays filled with integers) and 700x (!!) slower (if I compare large arrays filled with objects). Obviously being implemented in js as opposed to presumably C++ will necessitate a 2-10x performance hit, something seems suboptimal here because this is a lot slower than that.

I first became aware of the issue being in this library by seeing it show up in the chrome profiler. I haven't reviewed the code yet, but based on the flamegraph that I saw, the implementation appears to be a recursive one. And that doesn't bode well for performance, but I would expect even a recursive implementation to be faster than what I'm seeing.

Please let me know if any of this is unclear.

主要言語
JavaScript
スター
792
フォーク
107
平均マージ
9日 20時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

inspect-js/node-deep-equal のほかの issue

inspect-js/node-deep-equal の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。