Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont revalidate on windows #472

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion ext/bootsnap/bootsnap.c
Expand Up @@ -38,6 +38,10 @@
#define RB_UNLIKELY(x) (x)
#endif

#ifdef HAVE_FDATASYNC
#define BS_REVALIDATE_CACHE 1
#endif

/*
* An instance of this key is written as the first 64 bytes of each cache file.
* The mtime and size members track whether the file contents have changed, and
Expand Down Expand Up @@ -319,7 +323,15 @@ static enum cache_status cache_key_equal_fast_path(struct bs_cache_key *k1,
k1->ruby_platform == k2->ruby_platform &&
k1->compile_option == k2->compile_option &&
k1->ruby_revision == k2->ruby_revision && k1->size == k2->size) {
return (k1->mtime == k2->mtime) ? hit : stale;
if (k1->mtime == k2->mtime) {
return hit;
} else {
#ifdef BS_REVALIDATE_CACHE
return stale;
#else
return miss;
#endif
}
}
return miss;
}
Expand Down
4 changes: 4 additions & 0 deletions test/compile_cache_test.rb
Expand Up @@ -160,6 +160,8 @@ def test_dont_store_cache_after_a_stale_when_readonly
end

def test_dont_revalidate_when_readonly
skip("Not on Windows") if RUBY_PLATFORM.match?(/mswin|mingw|cygwin/)

path = Help.set_file("a.rb", "a = a = 3", 100)
load(path)

Expand Down Expand Up @@ -220,6 +222,8 @@ def test_instrumentation_miss
end

def test_instrumentation_revalidate
skip("Not on Windows") if RUBY_PLATFORM.match?(/mswin|mingw|cygwin/)

file_path = Help.set_file("a.rb", "a = a = 3", 100)
load(file_path)
FileUtils.touch("a.rb", mtime: File.mtime("a.rb") + 42)
Expand Down