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

JETAnalyzer: ignore x::Any == y::Concrete potentially returning missing within analyze_from_definition #543

Merged
merged 1 commit into from
Jun 25, 2023

Conversation

aviatesk
Copy link
Owner

In the analyze_from_definitions mode, the analysis begins with the method signature. However, these signatures can often be abstract, leading to situations where, in the case of x == y, one side might be concretely inferred, while the other side is not. This can lead to scenarios where the analysis might proceed while considering the possibility that x == y could return missing, and subsequently result in an error report, which, as discussed in #542, is usually an undesired false positive.

analyze_from_definitions was initially designed as an entry point for easy analysis, even at the cost of accuracy. Therefore, it might be better to simply widen the inferred return type
(x == y)::Union{Bool,Missing} to ::Any, thereby reducing potential errors. This should not apply to interactive entry points where the input concrete argument types are given at the analysis starting point. In these cases, the possibility of missing being returned should still be considered.

A bit off-topic, but while making this change, I realized that the current design of ReportPass might not be functioning as effectively as hoped. Originally, ReportPass was meant to allow users well-versed in JET internals to completely ignore specific reports, thereby deleting associated calculations (which can not be achieved by filtering out reports after the analysis has been completed). However, there seems to be a lack of such advanced users at present, and this is inadvertently increasing the complexity of the code base, potentially discouraging potential contributors. It might be beneficial to shift towards a simpler configuration style that can control specific behaviors of the analysis with in the short term.

fix #542

… `analyze_from_definition`

In the `analyze_from_definitions` mode, the analysis begins with the
method signature. However, these signatures can often be abstract,
leading to situations where, in the case of `x == y`, one side might be
concretely inferred, while the other side is not. This can lead to
scenarios where the analysis might proceed while considering the
possibility that `x == y` could return `missing`, and subsequently
result in an error report, which, as discussed in #542, is usually an
undesired false positive.

`analyze_from_definitions` was initially designed as an entry point for
easy analysis, even at the cost of accuracy. Therefore, it might be
better to simply widen the inferred return type
`(x == y)::Union{Bool,Missing}` to `::Any`, thereby reducing potential
errors. This should not apply to interactive entry points where the
input concrete argument types are given at the analysis starting point.
In these cases, the possibility of `missing` being returned should still
be considered.

A bit off-topic, but while making this change, I realized that the
current design of `ReportPass` might not be functioning as effectively
as hoped. Originally, `ReportPass` was meant to allow users well-versed
in JET internals to completely ignore specific reports, thereby deleting
associated calculations (which can not be achieved by filtering out
reports after the analysis has been completed). However, there seems to
be a lack of such advanced users at present, and this is inadvertently
increasing the complexity of the code base, potentially discouraging
potential contributors. It might be beneficial to shift towards a
simpler configuration style that can control specific behaviors of the
analysis with in the short term.

fix #542
@aviatesk aviatesk changed the title ignore x::Any == y::Concrete potentially returning missing within analyze_from_definition JETAnalyzer: ignore x::Any == y::Concrete potentially returning missing within analyze_from_definition Jun 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (cbe53e3) 89.81% compared to head (794c328) 89.81%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #543   +/-   ##
=======================================
  Coverage   89.81%   89.81%           
=======================================
  Files          10       10           
  Lines        3053     3055    +2     
=======================================
+ Hits         2742     2744    +2     
  Misses        311      311           
Impacted Files Coverage Δ
src/analyzers/jetanalyzer.jl 87.67% <100.00%> (+0.05%) ⬆️
src/toplevel/virtualprocess.jl 94.47% <100.00%> (-0.01%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link

JET Benchmark Result

Judge result

Benchmark Report for /home/runner/work/JET.jl/JET.jl

Job Properties

  • Time of benchmarks:
  • Target: 25 Jun 2023 - 16:25
  • Baseline: 25 Jun 2023 - 16:39
  • Package commits:
  • Target: 9e7426
  • Baseline: cbe53e
  • Julia commits:
  • Target: dd1f03
  • Baseline: dd1f03
  • Julia command flags:
  • Target: None
  • Baseline: None
  • Environment variables:
  • Target: None
  • Baseline: None

Results

A ratio greater than 1.0 denotes a possible regression (marked with ❌), while a ratio less
than 1.0 denotes a possible improvement (marked with ✅). Only significant results - results
that indicate possible regressions or improvements - are shown below (thus, an empty table means that all
benchmark results remained invariant between builds).

ID time ratio memory ratio
["First-Time-To-JET", "rand(Bool)"] 1.15 (5%) ❌ 1.00 (1%)
["JETAnalyzer{BasicPass}", "identity(nothing)"] 1.06 (5%) ❌ 1.00 (1%)
["JETAnalyzer{SoundPass}", "identity(nothing)"] 0.94 (5%) ✅ 1.00 (1%)
["JETAnalyzer{SoundPass}", "sum(\"julia\") (cached)"] 1.07 (5%) ❌ 1.00 (1%)

Benchmark Group List

Here's a list of all the benchmark groups executed by this job:

  • ["First-Time-To-JET"]
  • ["JETAnalyzer{BasicPass} top-level"]
  • ["JETAnalyzer{BasicPass}"]
  • ["JETAnalyzer{SoundPass}"]
  • ["OptAnalyzer"]
  • ["show(::IO, ::JETCallResult)"]

Julia versioninfo

Target

Julia Version 1.10.0-DEV.1564
Commit dd1f03df8d3 (2023-06-25 12:01 UTC)
Platform Info:
 OS: Linux (x86_64-linux-gnu)
 Ubuntu 22.04.2 LTS
 uname: Linux 5.15.0-1040-azure #47-Ubuntu SMP Thu Jun 1 19:38:24 UTC 2023 x86_64 x86_64
 CPU: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz: 
 speed user nice sys idle irq
 #1 2593 MHz 5970 s 0 s 243 s 3671 s 0 s
 #2 2593 MHz 4210 s 0 s 303 s 5348 s 0 s
 Memory: 6.7694854736328125 GB (4662.08203125 MB free)
 Uptime: 996.08 sec
 Load Avg: 1.0 1.02 0.8
 WORD_SIZE: 64
 LIBM: libopenlibm
 LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512)
 Threads: 1 on 2 virtual cores

Baseline

Julia Version 1.10.0-DEV.1564
Commit dd1f03df8d3 (2023-06-25 12:01 UTC)
Platform Info:
 OS: Linux (x86_64-linux-gnu)
 Ubuntu 22.04.2 LTS
 uname: Linux 5.15.0-1040-azure #47-Ubuntu SMP Thu Jun 1 19:38:24 UTC 2023 x86_64 x86_64
 CPU: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz: 
 speed user nice sys idle irq
 #1 2593 MHz 9660 s 0 s 492 s 7803 s 0 s
 #2 2593 MHz 8761 s 0 s 328 s 8845 s 0 s
 Memory: 6.7694854736328125 GB (4652.51953125 MB free)
 Uptime: 1804.75 sec
 Load Avg: 1.0 1.05 1.0
 WORD_SIZE: 64
 LIBM: libopenlibm
 LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512)
 Threads: 1 on 2 virtual cores

Target result

Benchmark Report for /home/runner/work/JET.jl/JET.jl

Job Properties

  • Time of benchmark: 25 Jun 2023 - 16:25
  • Package commit: 9e7426
  • Julia commit: dd1f03
  • Julia command flags: None
  • Environment variables: None

Results

Below is a table of this job's results, obtained by running the benchmarks.
The values listed in the ID column have the structure [parent_group, child_group, ..., key], and can be used to
index into the BaseBenchmarks suite to retrieve the corresponding benchmarks.
The percentages accompanying time and memory values in the below table are noise tolerances. The "true"
time/memory value for a given benchmark is expected to fall within this percentage of the reported value.
An empty cell means that the value was zero.

ID time GC time memory allocations
["First-Time-To-JET", "package loading"] 246.061 ms (5%) 64.73 KiB (1%) 19
["First-Time-To-JET", "rand(Bool)"] 568.972 ms (5%) 65.14 KiB (1%) 19
["First-Time-To-JET", "sum(\"julia\")"] 195.258 ms (5%) 65.14 KiB (1%) 19
["JETAnalyzer{BasicPass} top-level", "demo"] 52.782 ms (5%) 2.28 MiB (1%) 39818
["JETAnalyzer{BasicPass} top-level", "self analysis"] 11.741 s (5%) 1.070 s 1.25 GiB (1%) 23450952
["JETAnalyzer{BasicPass} top-level", "simple"] 9.198 ms (5%) 1.87 MiB (1%) 32711
["JETAnalyzer{BasicPass}", "identity(nothing)"] 90.903 μs (5%) 7.19 KiB (1%) 102
["JETAnalyzer{BasicPass}", "println(QuoteNode(nothing))"] 164.836 ms (5%) 38.57 MiB (1%) 727835
["JETAnalyzer{BasicPass}", "rand(Bool)"] 48.048 ms (5%) 12.01 MiB (1%) 221033
["JETAnalyzer{BasicPass}", "sum(\"julia\") (cached)"] 150.004 μs (5%) 14.77 KiB (1%) 201
["JETAnalyzer{BasicPass}", "sum(\"julia\")"] 6.705 ms (5%) 1.70 MiB (1%) 30161
["JETAnalyzer{SoundPass}", "identity(nothing)"] 86.702 μs (5%) 7.19 KiB (1%) 102
["JETAnalyzer{SoundPass}", "println(QuoteNode(nothing))"] 245.817 ms (5%) 35.792 ms 66.11 MiB (1%) 842667
["JETAnalyzer{SoundPass}", "rand(Bool)"] 47.134 ms (5%) 13.68 MiB (1%) 235500
["JETAnalyzer{SoundPass}", "sum(\"julia\") (cached)"] 164.804 μs (5%) 18.67 KiB (1%) 238
["JETAnalyzer{SoundPass}", "sum(\"julia\")"] 6.241 ms (5%) 1.76 MiB (1%) 31275
["OptAnalyzer", "identity(nothing)"] 148.204 μs (5%) 25.41 KiB (1%) 363
["OptAnalyzer", "println(QuoteNode(nothing))"] 564.395 ms (5%) 51.359 ms 215.58 MiB (1%) 3155539
["OptAnalyzer", "rand(Bool)"] 31.485 ms (5%) 13.70 MiB (1%) 202309
["OptAnalyzer", "sum(\"julia\") (cached)"] 276.607 μs (5%) 57.67 KiB (1%) 790
["OptAnalyzer", "sum(\"julia\")"] 15.039 ms (5%) 5.82 MiB (1%) 86640
["show(::IO, ::JETCallResult)", "report_call"] 5.166 ms (5%) 656.96 KiB (1%) 6893
["show(::IO, ::JETCallResult)", "report_opt"] 23.101 μs (5%) 632 bytes (1%) 14

Benchmark Group List

Here's a list of all the benchmark groups executed by this job:

  • ["First-Time-To-JET"]
  • ["JETAnalyzer{BasicPass} top-level"]
  • ["JETAnalyzer{BasicPass}"]
  • ["JETAnalyzer{SoundPass}"]
  • ["OptAnalyzer"]
  • ["show(::IO, ::JETCallResult)"]

Julia versioninfo

Julia Version 1.10.0-DEV.1564
Commit dd1f03df8d3 (2023-06-25 12:01 UTC)
Platform Info:
 OS: Linux (x86_64-linux-gnu)
 Ubuntu 22.04.2 LTS
 uname: Linux 5.15.0-1040-azure #47-Ubuntu SMP Thu Jun 1 19:38:24 UTC 2023 x86_64 x86_64
 CPU: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz: 
 speed user nice sys idle irq
 #1 2593 MHz 5970 s 0 s 243 s 3671 s 0 s
 #2 2593 MHz 4210 s 0 s 303 s 5348 s 0 s
 Memory: 6.7694854736328125 GB (4662.08203125 MB free)
 Uptime: 996.08 sec
 Load Avg: 1.0 1.02 0.8
 WORD_SIZE: 64
 LIBM: libopenlibm
 LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512)
 Threads: 1 on 2 virtual cores

Baseline result

Benchmark Report for /home/runner/work/JET.jl/JET.jl

Job Properties

  • Time of benchmark: 25 Jun 2023 - 16:39
  • Package commit: cbe53e
  • Julia commit: dd1f03
  • Julia command flags: None
  • Environment variables: None

Results

Below is a table of this job's results, obtained by running the benchmarks.
The values listed in the ID column have the structure [parent_group, child_group, ..., key], and can be used to
index into the BaseBenchmarks suite to retrieve the corresponding benchmarks.
The percentages accompanying time and memory values in the below table are noise tolerances. The "true"
time/memory value for a given benchmark is expected to fall within this percentage of the reported value.
An empty cell means that the value was zero.

ID time GC time memory allocations
["First-Time-To-JET", "package loading"] 247.850 ms (5%) 64.73 KiB (1%) 19
["First-Time-To-JET", "rand(Bool)"] 494.453 ms (5%) 65.14 KiB (1%) 19
["First-Time-To-JET", "sum(\"julia\")"] 195.271 ms (5%) 65.14 KiB (1%) 19
["JETAnalyzer{BasicPass} top-level", "demo"] 52.588 ms (5%) 2.28 MiB (1%) 39818
["JETAnalyzer{BasicPass} top-level", "self analysis"] 11.946 s (5%) 1.085 s 1.25 GiB (1%) 23449218
["JETAnalyzer{BasicPass} top-level", "simple"] 8.965 ms (5%) 1.86 MiB (1%) 32711
["JETAnalyzer{BasicPass}", "identity(nothing)"] 85.803 μs (5%) 7.19 KiB (1%) 102
["JETAnalyzer{BasicPass}", "println(QuoteNode(nothing))"] 166.998 ms (5%) 38.57 MiB (1%) 727835
["JETAnalyzer{BasicPass}", "rand(Bool)"] 47.698 ms (5%) 12.01 MiB (1%) 221033
["JETAnalyzer{BasicPass}", "sum(\"julia\") (cached)"] 147.903 μs (5%) 14.77 KiB (1%) 201
["JETAnalyzer{BasicPass}", "sum(\"julia\")"] 6.692 ms (5%) 1.70 MiB (1%) 30161
["JETAnalyzer{SoundPass}", "identity(nothing)"] 91.902 μs (5%) 7.19 KiB (1%) 102
["JETAnalyzer{SoundPass}", "println(QuoteNode(nothing))"] 240.826 ms (5%) 34.244 ms 65.59 MiB (1%) 842603
["JETAnalyzer{SoundPass}", "rand(Bool)"] 46.556 ms (5%) 13.68 MiB (1%) 235500
["JETAnalyzer{SoundPass}", "sum(\"julia\") (cached)"] 154.204 μs (5%) 18.67 KiB (1%) 238
["JETAnalyzer{SoundPass}", "sum(\"julia\")"] 6.279 ms (5%) 1.76 MiB (1%) 31275
["OptAnalyzer", "identity(nothing)"] 144.805 μs (5%) 25.41 KiB (1%) 363
["OptAnalyzer", "println(QuoteNode(nothing))"] 556.282 ms (5%) 50.135 ms 215.58 MiB (1%) 3155539
["OptAnalyzer", "rand(Bool)"] 31.308 ms (5%) 13.70 MiB (1%) 202309
["OptAnalyzer", "sum(\"julia\") (cached)"] 271.408 μs (5%) 57.67 KiB (1%) 790
["OptAnalyzer", "sum(\"julia\")"] 14.735 ms (5%) 5.82 MiB (1%) 86640
["show(::IO, ::JETCallResult)", "report_call"] 5.154 ms (5%) 656.96 KiB (1%) 6893
["show(::IO, ::JETCallResult)", "report_opt"] 22.401 μs (5%) 632 bytes (1%) 14

Benchmark Group List

Here's a list of all the benchmark groups executed by this job:

  • ["First-Time-To-JET"]
  • ["JETAnalyzer{BasicPass} top-level"]
  • ["JETAnalyzer{BasicPass}"]
  • ["JETAnalyzer{SoundPass}"]
  • ["OptAnalyzer"]
  • ["show(::IO, ::JETCallResult)"]

Julia versioninfo

Julia Version 1.10.0-DEV.1564
Commit dd1f03df8d3 (2023-06-25 12:01 UTC)
Platform Info:
 OS: Linux (x86_64-linux-gnu)
 Ubuntu 22.04.2 LTS
 uname: Linux 5.15.0-1040-azure #47-Ubuntu SMP Thu Jun 1 19:38:24 UTC 2023 x86_64 x86_64
 CPU: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz: 
 speed user nice sys idle irq
 #1 2593 MHz 9660 s 0 s 492 s 7803 s 0 s
 #2 2593 MHz 8761 s 0 s 328 s 8845 s 0 s
 Memory: 6.7694854736328125 GB (4652.51953125 MB free)
 Uptime: 1804.75 sec
 Load Avg: 1.0 1.05 1.0
 WORD_SIZE: 64
 LIBM: libopenlibm
 LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512)
 Threads: 1 on 2 virtual cores

Runtime information

Runtime Info
BLAS #threads 1
BLAS.vendor() lbt
Sys.CPU_THREADS 2

lscpu output:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
CPU family: 6
Model: 85
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
Stepping: 7
BogoMIPS: 5187.81
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clflushopt avx512cd avx512bw avx512vl xsaveopt xsavec xsaves md_clear
Hypervisor vendor: Microsoft
Virtualization type: full
L1d cache: 64 KiB (2 instances)
L1i cache: 64 KiB (2 instances)
L2 cache: 2 MiB (2 instances)
L3 cache: 35.8 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0,1
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT Host state unknown
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed: Vulnerable
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT Host state unknown

Cpu Property Value
Brand Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Vendor :Intel
Architecture :Skylake
Model Family: 0x06, Model: 0x55, Stepping: 0x07, Type: 0x00
Cores 2 physical cores, 2 logical cores (on executing CPU)
No Hyperthreading hardware capability detected
Clock Frequencies Not supported by CPU
Data Cache Level 1:3 : (32, 1024, 36608) kbytes
64 byte cache line size
Address Size 48 bits virtual, 46 bits physical
SIMD 512 bit = 64 byte max. SIMD vector size
Time Stamp Counter TSC is accessible via rdtsc
TSC increased at every clock cycle (non-invariant TSC)
Perf. Monitoring Performance Monitoring Counters (PMC) are not supported
Hypervisor Yes, Microsoft

@aviatesk aviatesk merged commit c466a1c into master Jun 25, 2023
@aviatesk aviatesk deleted the avi/542 branch June 25, 2023 16:45
@aviatesk aviatesk restored the avi/542 branch June 26, 2023 05:08
@aviatesk aviatesk deleted the avi/542 branch June 26, 2023 05:08
@gdalle
Copy link

gdalle commented Jun 26, 2023

Even though it solves my problem from JuliaGraphs/Graphs.jl#249, I'm a bit skeptical about this. I thought @timholy also agreed that returning missing may sometimes be a desirable feature of the code? Can this behavior be turned on/off?

@aviatesk
Copy link
Owner Author

Currently, this behavior is only enabled in report_package and not in other scenarios. However, it might be beneficial to make it configurable, regardless of the default behavior we decide on.

@timholy
Copy link
Collaborator

timholy commented Jun 26, 2023

I agree that having it report_package makes a ton of sense. Is it still loose if the package happens to have a method with a concrete signature, or does it default to the behavior of report_call in that case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a configuration to ignore the case when x == y return missing?
4 participants