git コマンドの実行を1回にまとめて高速化する#105
Merged
Merged
Conversation
Member
|
なるほど、これでよさそうですね。ありがとうございます。 |
Member
|
デプロイしました。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
run.pyの実行において、ファイルの数だけ実行されるgit logがボトルネックになっていました。そこで、1回の git コマンド実行ですべてのコミット情報を出力し、それを解析する方法を提案します。
提案
git logに--name-onlyをつけて実行すると、以下のように各コミットで編集されたファイルの一覧が出力されます。新しい順に出力されるので、上から見ていって各ファイルが最初に登場するコミットのタイムスタンプおよび著者を調べることで、従来と同じような情報が得られます。
$ git log --date=iso --pretty='format:%at %an' --name-only 1769871600 Author1 path/to/file1.md path/to/file2.md 1767193200 Author2 path/to/file3.md実行時間
手元の環境では、
run.pyの実行時間が 49.2 秒から 23.7 秒に改善しました。従来と結果が変わるケース
ファイルごとに
git logするのとは結果が変わるケースがあります。別のブランチで編集し、その編集を取り消し、マージした場合、従来は取り消したコミットは考慮されませんでしたが、提案手法では取り消したコミットの情報を参照します。
次の6つのファイルが該当します。これらは cpprefjp/site#1466 で一度編集した後、元に戻してマージされたファイルです。
また、従来はマージコミットの時刻だったが、提案手法ではマージコミット直前の通常のコミットの時刻になるケースがあります。
次のファイルが該当します。これに関しては原因がわかっておらず、そもそもなぜ従来はマージコミットの時刻が参照されていたのかが謎です。