ponponUSA 氏の更新をさらに取り入れ#48
Conversation
- Yamlロードをキャッシュする - 進捗表示I/Oを間引く - Template (ERB) の再コンパイルを避ける
There was a problem hiding this comment.
Pull Request Overview
This PR integrates updates from ponponUSA, primarily focused on performance improvements through caching, YJIT support, and Bootsnap integration. The changes introduce template compilation caching, section data caching, and optimizations to reduce I/O overhead during novel conversion processes.
Key changes:
- Added YJIT flag and Bootsnap for faster Ruby execution and load times
- Implemented template compilation caching to avoid re-parsing ERB templates
- Added section data caching and batch conversion to reduce redundant operations
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| narou.rb | Enabled YJIT for Ruby interpreter and integrated Bootsnap for performance optimization |
| narou.gemspec | Added bootsnap dependency (v1.18.6+) to support the new caching infrastructure |
| lib/template.rb | Refactored template handling with compile/render separation and added compilation caching |
| lib/novelconverter.rb | Optimized EPUB subject handling to use in-memory operations, added template/section caching, and implemented batch conversion |
| lib/converterbase.rb | Moved device initialization earlier and added convert_multi method for batch processing, reduced progress bar update frequency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # target_binary_version から参照される @@src_version は | ||
| # テンプレート内で <%= Template.target_binary_version 1.1 %> みたいに呼ばれる想定 | ||
| # なので、ここでは設定しない。テンプレの中から呼ばれた時点で | ||
| # @@src_version が更新され、invalid_templace_version? が機能する |
There was a problem hiding this comment.
Corrected spelling of 'invalid_templace_version' to 'invalid_template_version' in the comment.
|
|
||
| on(:"convert_main.loop") do |i| | ||
| progressbar.output(i) if progressbar | ||
| # 毎回ではな10件ごとに絞る |
There was a problem hiding this comment.
Corrected incomplete phrase '毎回ではな10件ごとに絞る' to '毎回ではなく10件ごとに絞る' in the comment.
| # 毎回ではな10件ごとに絞る | |
| # 毎回ではなく10件ごとに絞る |
|
|
||
| @inspector.subtitle = section["subtitle"] | ||
| section["subtitle"] = @converter.convert(section["subtitle"], "subtitle") | ||
| # キャッシュを壊さないようディープ寄りにdup |
There was a problem hiding this comment.
[nitpick] The comment '寄り' (towards) is vague. Consider clarifying whether this is a shallow or deep copy, e.g., '浅いコピーだがelementは別途コピー' (shallow copy but element is separately copied) to better describe the duplication strategy.
| # キャッシュを壊さないようディープ寄りにdup | |
| # キャッシュを壊さないよう浅いコピーだがelementは別途コピー |
| # キャッシュを壊さないようディープ寄りにdup | ||
| # (chapter/subtitle/elementなど後で書き換えるので) | ||
| section = original_section.dup | ||
| section["element"] = original_section["element"].dup |
There was a problem hiding this comment.
This is not a deep copy. Only the top-level hash and the 'element' hash are duplicated. If 'element' contains nested mutable objects (arrays or hashes), they will still be shared with the original. Consider using deep copy methods like Marshal.load(Marshal.dump(original_section)) or a recursive duplication if nested immutability is required.
| # キャッシュを壊さないようディープ寄りにdup | |
| # (chapter/subtitle/elementなど後で書き換えるので) | |
| section = original_section.dup | |
| section["element"] = original_section["element"].dup | |
| # キャッシュを壊さないよう完全なディープコピーを作成 | |
| # (chapter/subtitle/elementなど後で書き換えるので) | |
| section = Marshal.load(Marshal.dump(original_section)) |
高速かがメイン
Web UI 周りの不具合は後にこっちで修正できるようにせねば...