Updates spk's FileMatcher to lazily create its internal gitignore object#1290
Updates spk's FileMatcher to lazily create its internal gitignore object#1290
FileMatcher to lazily create its internal gitignore object#1290Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
crates/spk-schema/crates/foundation/src/spec_ops/file_matcher.rs
Outdated
Show resolved
Hide resolved
| pub struct FileMatcher { | ||
| rules: Vec<String>, | ||
| gitignore: ignore::gitignore::Gitignore, | ||
| gitignore: Arc<Mutex<Option<ignore::gitignore::Gitignore>>>, |
There was a problem hiding this comment.
Profile first, but ArcSwap may be a cheaper way to manage this field. Instead of creating numerous Mutex instances. I'm more concerned about this significantly slowing down builds for packages with a lot of files and calling matches on each file.
There was a problem hiding this comment.
maybe a OnceCell to leverage get_or_try_init? Maybe that's been tried, but leaving the note anyway
1c26c2e to
f01b410
Compare
|
In a discussion today, we realised that this PR is about to be redundant because the type splitting between recipe and package (build spec) will mean the FileMatcher field won't be in the v1 packages any more. |
… first call to matches() method. Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
…hing lazy initialisation. Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
…dly trying to initialise it when that will fail Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
f01b410 to
65c410e
Compare
This updates spk's
FileMatcherobjects to lazily create its internalgitignoreobject on first call to thematches()method.The
FileMatcherand itsgitignorefield was accounting for about a quarter of the load/read time for a package build spec. The matching is only carried out when building a package, so setting it up lazily saves time in other parts of spk (e.g. a solve that reads 15k package build specs).Todo: