Performance idea: Partition before executing current uniform indentation search
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- ruby
- 領域
- performance, tooling
調査の方向性
schneems/partition ブランチの失敗しているテストから始め、現在の検索アルゴリズムによる Ripper.parse の呼び出しを追跡してください。インデントと kw/end のペアがどのように処理されているかを読み、その後、パーティショニングまたはより大きな展開ステップを既存の動作と比較してください。九千行のケースで timeout を回避しながら、構文エラー結果の品質を維持できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This is a failing test: https://github.com/zombocom/dead_end/tree/schneems/partition. The file is nine thousand lines and it takes a tad over 1 second to parse which means it hits the timeout.
We are already fairly well optimized for the current algorithm so to be able to handle arbitrarily large-sized files we will need a different strategy.
The current algorithm takes relatively small steps in the interest in producing a good end result. That takes a long time.
Here's my general idea: We can split up the file into multiple large chunks before running the current fine-grained algorithm. At a high level: split up the file into 2 parts and see which holds the syntax error. If we can isolate the problem to only half the file then we've dropped processing time in half (relatively). We can run this partition step a few times.
The catch is that some files (such as the one in the failing test cannot be split without introducing a syntax error (since it starts with a class declaration and ends with an end). To account for this we will need to split in a way that's lexically aware.
For example on that file, I think the algorithm would determine that it can't do much with indentation 0 so it would have to go to the next indentation, there it could see there are N chunks of kw/end pairs, it could divide into N/2 and see if one of those sections holds all of the syntax errors. We could perform this division several times to arrive at a subset of the larger problem, then run the original search array on it.
The challenge is, that we will essentially need to build an inverse of the existing algorithm. Instead of starting with a single line and expanding towards indentation zero, we'll start with all the lines and reduce towards indentation max.
The expensive part is checking code is valid via Ripper.parse, sub dividing large files into smaller files can help us isolate problems sections with fewer parse calls, but we've got to make sure the results are as good.
An alternative idea would be to use the existing search/expansion logic to perform more expansions until a set of N blocks are generated then check all of them at once. Then once the document problem is isolated, go back and re-parse only the N blocks with the existing. Algorithm. (Basically the same idea as partitioning, but we're working from the same direction as the current algorithm, just taking larger steps (which means fewer Ripper.parse) calls. However we would still need a way to sub-divide the blocks with this process in the terminal case that the syntax error is on indentation zero and the document is massive and all within one kw/end pair.
- 主要言語
- Ruby
- スター
- 350
- フォーク
- 17
- 平均マージ
- 48分
- マージ済み PR(30日)
- 5
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/syntax_suggest のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
ruby/syntax_suggest#258 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
ruby/syntax_suggest#206 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
ruby/syntax_suggest#205 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ruby/syntax_suggest#171 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
ruby/syntax_suggest#109 · コメント 1 件 ·
ruby/syntax_suggest の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
TheOdinProject/curriculum#31417 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
glossarist/glossarist-ruby#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·