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

Don't use pkgimage for package if any includes fall in tracked path for coverage or alloc tracking #48183

Closed

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jan 9, 2023

Fixes #48071

Makes disabling pkgimages specific to the package being coverage (or alloc) tracked.
i.e. should increase the testing of pkgimages in ecosystem CI

Does more than this need to be done @vchuravy ? I'm guessing so given code_coverage != 0 disables pkgimages globally, I believe?

@IanButterworth IanButterworth added backport 1.9 Change should be backported to release-1.9 pkgimage labels Jan 9, 2023
@IanButterworth IanButterworth force-pushed the ib/pkgimage_coverage branch 2 times, most recently from 04a742f to 07203d2 Compare January 9, 2023 04:14
base/loading.jl Outdated Show resolved Hide resolved
base/loading.jl Outdated Show resolved Hide resolved
@vchuravy
Copy link
Member

vchuravy commented Jan 9, 2023

You will also need to make sure that we don't create a "poisoned" cachefile. Cachefile creation happens here

cpu_target = nothing
you will want to prevent compile-cache from propagating. Ideally the caller to create_expr_cache would get it rid and pass in nothing for the object output.

Then you need to adapt the command line checking and allow --pkgimage and --code-coverage=3 to co-exist (but only if we are not in precompile mode).

@KristofferC KristofferC mentioned this pull request Jan 10, 2023
41 tasks
@KristofferC KristofferC mentioned this pull request Jan 17, 2023
35 tasks
@IanButterworth IanButterworth marked this pull request as draft January 26, 2023 15:37
@KristofferC KristofferC mentioned this pull request Feb 20, 2023
50 tasks
@KristofferC KristofferC mentioned this pull request Mar 7, 2023
52 tasks
@KristofferC KristofferC mentioned this pull request Apr 9, 2023
26 tasks
@KristofferC KristofferC mentioned this pull request May 8, 2023
51 tasks
@KristofferC KristofferC mentioned this pull request Jun 6, 2023
36 tasks
@KristofferC KristofferC mentioned this pull request Jul 11, 2023
35 tasks
@IanButterworth IanButterworth added the backport 1.10 Change should be backported to the 1.10 release label Aug 1, 2023
KristofferC added a commit that referenced this pull request Aug 18, 2023
Backported PRs:
- [x] #47782 <!-- Generalize Bool parse method to AbstractString -->
- [x] #48634 <!-- Remove unused "deps" mechanism in internal sorting
keywords [NFC] -->
- [x] #49931 <!-- Lock finalizers' lists at exit -->
- [x] #50064 <!-- Fix numbered prompt with input only with comment -->
- [x] #50474 <!-- docs: Fix a `!!! note` which was miscapitalized -->
- [x] #50516 <!-- Fix visibility of assert on GCC12/13 -->
- [x] #50635 <!-- `versioninfo()`: include build info and unofficial
warning -->
- [x] #49915 <!-- Revert "Remove number / vector (#44358)" -->
- [x] #50781 <!-- fix `bit_map!` with aliasing -->
- [x] #50845 <!-- fix #50438, use default pool for at-threads -->
- [x] #49031 <!-- Update inference.md -->
- [x] #50289 <!-- Initialize prev_nold and nold in gc_reset_page -->
- [x] #50559 <!-- Expand kwcall lowering positional default check to
vararg -->
- [x] #49582 <!-- Update HISTORY.md for `DelimitedFiles` -->
- [x] #50341 <!-- invokelatest docs should say not exported before 1.9
-->
- [x] #50525 <!-- only check that values are finite in `generic_lufact`
when `check=true` -->
- [x] #50444 <!-- Optimize getfield lowering to avoid boxing in some
cases -->
- [x] #50523 <!-- Avoid generic call in most cases for getproperty -->
- [x] #50860 <!-- Add `Base.get_extension` to docs/API -->
- [x] #50164 <!-- codegen: handle dead code with unsafe_store of FCA
pointers -->
- [x] #50568 <!-- `Array(::AbstractRange)` should return an `Array` -->
- [x] #50871 <!-- macOS: Don't inspect dead threadtls during exception
handling. -->

Need manual backport:
- [ ] #48542 <!-- Add docs on task-specific buffering using
multithreading -->
- [ ] #50591 <!-- build: fix various makefile bugs -->


Non-merged PRs with backport label:
- [ ] #50842 <!-- Avoid race conditions with recursive rm -->
- [ ] #50823 <!-- Make ranges more robust with unsigned indexes. -->
- [ ] #50663 <!-- Fix Expr(:loopinfo) codegen -->
- [ ] #49716 <!-- Update varinfo() docstring signature -->
- [ ] #49713 <!-- prevent REPL from erroring in numbered mode in some
situations -->
- [ ] #49573 <!-- Implement jl_cpu_pause on PPC64 -->
- [ ] #48726 <!-- fix macro expansion of property destructuring -->
- [ ] #48642 <!-- Use gc alloc instead of alloc typed in lowering -->
- [ ] #48183 <!-- Don't use pkgimage for package if any includes fall in
tracked path for coverage or alloc tracking -->
- [ ] #48050 <!-- improve `--heap-size-hint` arg handling -->
- [ ] #47615 <!-- Allow threadsafe access to buffer of type inference
profiling trees -->
@IanButterworth IanButterworth force-pushed the ib/pkgimage_coverage branch 2 times, most recently from 4641d14 to 3bb455a Compare November 4, 2023 22:47
@IanButterworth
Copy link
Member Author

IanButterworth commented Nov 5, 2023

@vchuravy this is largely working except that the no pkgimage .ji cache that is generated is recorded as pkgimage=yes, which I can't see why because the header writer uses jl_cache_flags which has been modified here.

┌ Debug: Allowing pkgimages=no for PNGFiles [f57f5aa1-a3ce-4bc8-8ab9-96f992907883] because it falls in coverage/allocation tracking path /Users/ian/Documents/GitHub/PNGFiles.jl/
└ @ Base loading.jl:3192
┌ Debug: Rejecting cache file /Users/ian/.julia/compiled/v1.11/PNGFiles/yIZEc_zCVpb.ji for PNGFiles [f57f5aa1-a3ce-4bc8-8ab9-96f992907883] since the flags are mismatched
│   current session: use_pkgimages = false, debug_level = 1, check_bounds = 0, inline = true, opt_level = 2
│   cache file:      use_pkgimages = true, debug_level = 1, check_bounds = 0, inline = true, opt_level = 0
└ @ Base loading.jl:3198

Copy link
Member

@vchuravy vchuravy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks about right

for chi in includes
startswith(chi.filename, tracked_path) || continue
@debug "Allowing pkgimages=no for $modkey because it falls in coverage/allocation tracking path $tracked_path"
current_flags &= 0b11111110 # disable pkgimages flag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid a magic number here? Maybe CacheFlags(current_flags, pkgimage=no)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_flags needs to be passed into the c func jl_match_cache_flags so I didn't think the transform should be done to the julia struct

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The struct is the only thing in Julia that knows the position of the bits. I am trying to avoid a circumstance where we move the bits around and forget to update this.

@@ -599,20 +599,20 @@ JL_DLLEXPORT uint8_t jl_cache_flags(void)
{
// OOICCDDP
uint8_t flags = 0;
flags |= (jl_options.use_pkgimages & 1); // 0-bit
// don't use use_pkgimages here because no outputo overrides it
flags |= ((jl_options.outputo == NULL || jl_options.outputo[0] == '\0') | 1); // 0-bit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit odd... Are you missing the negation? And | 1 won't it put the pkgimage bit high always?

@IanButterworth
Copy link
Member Author

Replaced by #52123

@IanButterworth IanButterworth deleted the ib/pkgimage_coverage branch November 15, 2023 03:24
@KristofferC KristofferC removed backport 1.9 Change should be backported to release-1.9 backport 1.10 Change should be backported to the 1.10 release labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code-coverage should be more precise in disabling package images
3 participants