Add config 'forcely_yield_count'

the default value 1000 would make a fiber yield on each 4ms on SSD

Apply yield counter in Dir.contents_signauture
Use contents_signature cache in Title.new
This commit is contained in:
Leeingnyo
2021-09-16 00:16:26 +09:00
parent 44a6f822cd
commit 70ab198a33
4 changed files with 13 additions and 8 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ class Title
@[YAML::Field(ignore: true)]
@cached_cover_url : String?
def initialize(@dir : String, @parent_id, cache : Hash(String, String)? = nil)
def initialize(@dir : String, @parent_id, cache = {} of String => String)
storage = Storage.default
@signature = Dir.signature dir
id = storage.get_title_id dir, signature
@@ -43,7 +43,7 @@ class Title
next if fn.starts_with? "."
path = File.join dir, fn
if File.directory? path
title = Title.new path, @id
title = Title.new path, @id, cache
next if title.entries.size == 0 && title.titles.size == 0
Library.default.title_hash[title.id] = title
@title_ids << title.id
@@ -73,7 +73,7 @@ class Title
def examine(context : ExamineContext) : Bool
return false unless Dir.exists? @dir # No title, Remove this
contents_signature = Dir.contents_signature @dir,
context["cached_contents_signature"]
context["cached_contents_signature"], context["file_counter"]
# Not changed. Reuse this
return true if @contents_signature == contents_signature