-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Programクラスのパフォーマンス改善 #55
Programクラスのパフォーマンス改善 #55
Conversation
Improve the time complexity of `get` and `exists` methods from O(N) to O(1). This change affects performance of the following functions: * Load time of program.json * findByNetworkIdAndReplace New private member variable `_itemMap` has been introduced, which maps program IDs to their associated ProgramItem objects.
ちなみに,この修正は #56 とは無関係です |
対応が遅くなりました。
|
書き換えてもいいのですが,以下について問題がないか判断をお願いします.
問題ないのであれば書き換えます.
|
まさに
と考えていますから、提案していただいたパフォーマンス改善の意図をそのまま生かす形で Map 使えたら Map 使ってみましょう 私もテストしますので、ぜひ書き換えてみてください。 |
了解です.念の為,以下の順番でコミットします.
2, 3の修正がまずかったら簡単に戻せるようにしておきます. |
The `Map` class keeps insertion order. So, we expect that the order of program items in new `Program.items` is the same as the old one, hopefully...
コミットログにも書きましたが, |
|
Dockerfile has been updated because it didn't work. In addition, the inconsistent line endings in Dockerfile have been fixed. docker-compose.yml has been added for test purpose. A data volume which mounted at /usr/local/var/db/mirakurun is created automatically when running `docker-compose up`. Use `docker-compose down` with the `-v` option if you want to remove the data volume at the shutdown. Or remove it manually using `docker voluem rm`.
単体テストなどがないため,とりあえず暫く動かしてみます |
一日程度動かしましたが, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要な変更とファイルが混じってしまっているようです
This reverts commit fbc67e1.
1c7acea でrevertしました. Dockerfileの修正とdocker-compose.ymlの追加だったので,revertしても本件の修正には影響を与えません. |
分離して #59 を作成しました. |
ありがとうございます。マージしました。 |
get
およびexists
メソッドの計算量をO(N)からO(1)に改善.これにより,以下のパフォーマンスが改善します.
program.json
の読み込み時間findByNetworkIdAndReplace
のブロック時間add
のたびに,_item
を線形検索していましたが,ほとんどの場合IDがマッチすることはないのでかなりの時間を消費していました.この修正により,
findByNetworkIdAndReplace
のブロック時間は問題にならない程度に速くなったので(Rock64でも1秒以下),findByNetworkIdAndReplace
の非同期化は不要となりました.そのため,async
およびawait
のみ削除しました.コメントにあるように,
_items
を_itemMap
に置き換えてしまうことも可能でしたが,そうしてしまうと,Programクラスの大部分を書き換えることになるため,置き換えはしませんでした.置き換えることで,splice
しなくて良くなるのでもう少し速くなるかもしれませんが,すでに十分速くなっているので,必要性は低いと考えています._items
と_itemMap
という似たものが2つあるのはよくないということでしたら,_items
を削除しますので,指摘をお願いします.