JuliaImages / DitherPunk.jl

Dithering algorithms in Julia.
MIT License
60 stars 3 forks source link

deprecate keyword color_space for ErrorDiffusion #72

Closed johnnychen94 closed 2 years ago

johnnychen94 commented 2 years ago

This is not type inferrable and would thus hurt the performance.

Changing the order of parameters is technically breaking, but I doubt people outside are depending on it. Thus an appropriate deprecation of color_space keyword should make this a transparent improvement.

codecov[bot] commented 2 years ago

Codecov Report

Merging #72 (fb22593) into master (7969627) will decrease coverage by 0.08%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   98.44%   98.36%   -0.09%     
==========================================
  Files          14       14              
  Lines         257      244      -13     
==========================================
- Hits          253      240      -13     
  Misses          4        4              
Impacted Files Coverage Δ
src/DitherPunk.jl 100.00% <ø> (ø)
src/error_diffusion.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7969627...fb22593. Read the comment docs.

github-actions[bot] commented 2 years ago
Benchmark result # Judge result # Benchmark Report for */home/runner/work/DitherPunk.jl/DitherPunk.jl* ## Job Properties * Time of benchmarks: - Target: 28 Apr 2022 - 07:57 - Baseline: 28 Apr 2022 - 07:59 * Package commits: - Target: 9f681d - Baseline: 796962 * Julia commits: - Target: bf5349 - Baseline: bf5349 * 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 :x:), while a ratio less than `1.0` denotes a possible improvement (marked with :white_check_mark:). 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 | |--------------------------------------------------|------------------------------|---------------| | `["closest color", "binary inplace"]` | 1.36 (5%) :x: | 1.00 (1%) | | `["closest color", "binary new"]` | 1.49 (5%) :x: | 1.00 (1%) | | `["closest color", "per-channel inplace"]` | 1.09 (5%) :x: | 1.00 (1%) | | `["error diffusion", "binary inplace"]` | 0.88 (5%) :white_check_mark: | 1.00 (1%) | | `["error diffusion", "binary new"]` | 0.90 (5%) :white_check_mark: | 1.00 (1%) | | `["error diffusion", "color inplace"]` | 1.17 (5%) :x: | 2.30 (1%) :x: | | `["ordered dithering", "color inplace"]` | 1.18 (5%) :x: | 1.00 (1%) | | `["ordered dithering", "color new"]` | 1.12 (5%) :x: | 1.00 (1%) | | `["ordered dithering", "per-channel inplace"]` | 1.16 (5%) :x: | 1.00 (1%) | | `["ordered dithering", "per-channel new"]` | 0.92 (5%) :white_check_mark: | 1.00 (1%) | | `["threshold dithering", "binary inplace"]` | 1.27 (5%) :x: | 1.00 (1%) | | `["threshold dithering", "binary new"]` | 1.34 (5%) :x: | 1.00 (1%) | ## Benchmark Group List Here's a list of all the benchmark groups executed by this job: - `["closest color"]` - `["error diffusion"]` - `["ordered dithering"]` - `["threshold dithering"]` ## Julia versioninfo ### Target ``` Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) Ubuntu 20.04.4 LTS uname: Linux 5.13.0-1022-azure #26~20.04.1-Ubuntu SMP Thu Apr 7 19:42:45 UTC 2022 x86_64 x86_64 CPU: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz: speed user nice sys idle irq #1 2095 MHz 2361 s 2 s 172 s 1365 s 0 s #2 2095 MHz 1572 s 1 s 178 s 2160 s 0 s Memory: 6.783603668212891 GB (3584.24609375 MB free) Uptime: 395.59 sec Load Avg: 1.04 0.84 0.41 WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512) ``` ### Baseline ``` Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) Ubuntu 20.04.4 LTS uname: Linux 5.13.0-1022-azure #26~20.04.1-Ubuntu SMP Thu Apr 7 19:42:45 UTC 2022 x86_64 x86_64 CPU: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz: speed user nice sys idle irq #1 2095 MHz 2441 s 2 s 178 s 2530 s 0 s #2 2095 MHz 2738 s 1 s 192 s 2235 s 0 s Memory: 6.783603668212891 GB (3775.87890625 MB free) Uptime: 521.17 sec Load Avg: 1.0 0.9 0.5 WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512) ``` --- # Target result # Benchmark Report for */home/runner/work/DitherPunk.jl/DitherPunk.jl* ## Job Properties * Time of benchmark: 28 Apr 2022 - 7:57 * Package commit: 9f681d * Julia commit: bf5349 * 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 | |--------------------------------------------------|----------------:|----------:|----------------:|------------:| | `["closest color", "binary inplace"]` | 7.767 μs (5%) | | 64.11 KiB (1%) | 2 | | `["closest color", "binary new"]` | 5.967 μs (5%) | | 64.11 KiB (1%) | 2 | | `["closest color", "color inplace"]` | 168.474 ms (5%) | | 36.50 MiB (1%) | 2359336 | | `["closest color", "color new"]` | 171.882 ms (5%) | | 36.48 MiB (1%) | 2357848 | | `["closest color", "per-channel inplace"]` | 1.015 ms (5%) | | 192.05 KiB (1%) | 2 | | `["closest color", "per-channel new"]` | 916.006 μs (5%) | | 192.05 KiB (1%) | 2 | | `["error diffusion", "binary inplace"]` | 945.413 μs (5%) | | 320.23 KiB (1%) | 5 | | `["error diffusion", "binary new"]` | 911.112 μs (5%) | | 320.23 KiB (1%) | 5 | | `["error diffusion", "color inplace"]` | 168.193 ms (5%) | | 36.81 MiB (1%) | 2359340 | | `["error diffusion", "color new"]` | 130.022 ms (5%) | | 16.01 MiB (1%) | 995660 | | `["error diffusion", "per-channel inplace"]` | 3.798 ms (5%) | | 960.42 KiB (1%) | 11 | | `["error diffusion", "per-channel new"]` | 4.128 ms (5%) | | 960.42 KiB (1%) | 11 | | `["ordered dithering", "binary inplace"]` | 97.501 μs (5%) | | 69.42 KiB (1%) | 5 | | `["ordered dithering", "binary new"]` | 92.001 μs (5%) | | 69.42 KiB (1%) | 5 | | `["ordered dithering", "color inplace"]` | 831.650 ms (5%) | 33.919 ms | 247.07 MiB (1%) | 14417965 | | `["ordered dithering", "color new"]` | 955.776 ms (5%) | 47.591 ms | 281.11 MiB (1%) | 16473466 | | `["ordered dithering", "per-channel inplace"]` | 1.200 ms (5%) | | 207.98 KiB (1%) | 11 | | `["ordered dithering", "per-channel new"]` | 1.014 ms (5%) | | 207.98 KiB (1%) | 11 | | `["threshold dithering", "binary inplace"]` | 15.001 μs (5%) | | 128.27 KiB (1%) | 7 | | `["threshold dithering", "binary new"]` | 13.500 μs (5%) | | 128.27 KiB (1%) | 7 | | `["threshold dithering", "per-channel inplace"]` | 960.306 μs (5%) | | 384.38 KiB (1%) | 8 | | `["threshold dithering", "per-channel new"]` | 1.032 ms (5%) | | 384.38 KiB (1%) | 8 | ## Benchmark Group List Here's a list of all the benchmark groups executed by this job: - `["closest color"]` - `["error diffusion"]` - `["ordered dithering"]` - `["threshold dithering"]` ## Julia versioninfo ``` Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) Ubuntu 20.04.4 LTS uname: Linux 5.13.0-1022-azure #26~20.04.1-Ubuntu SMP Thu Apr 7 19:42:45 UTC 2022 x86_64 x86_64 CPU: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz: speed user nice sys idle irq #1 2095 MHz 2361 s 2 s 172 s 1365 s 0 s #2 2095 MHz 1572 s 1 s 178 s 2160 s 0 s Memory: 6.783603668212891 GB (3584.24609375 MB free) Uptime: 395.59 sec Load Avg: 1.04 0.84 0.41 WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512) ``` --- # Baseline result # Benchmark Report for */home/runner/work/DitherPunk.jl/DitherPunk.jl* ## Job Properties * Time of benchmark: 28 Apr 2022 - 7:59 * Package commit: 796962 * Julia commit: bf5349 * 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 | |--------------------------------------------------|----------------:|----------:|----------------:|------------:| | `["closest color", "binary inplace"]` | 5.700 μs (5%) | | 64.11 KiB (1%) | 2 | | `["closest color", "binary new"]` | 4.000 μs (5%) | | 64.11 KiB (1%) | 2 | | `["closest color", "color inplace"]` | 167.478 ms (5%) | | 36.48 MiB (1%) | 2357848 | | `["closest color", "color new"]` | 165.058 ms (5%) | | 36.48 MiB (1%) | 2357848 | | `["closest color", "per-channel inplace"]` | 932.211 μs (5%) | | 192.05 KiB (1%) | 2 | | `["closest color", "per-channel new"]` | 914.411 μs (5%) | | 192.05 KiB (1%) | 2 | | `["error diffusion", "binary inplace"]` | 1.074 ms (5%) | | 320.23 KiB (1%) | 5 | | `["error diffusion", "binary new"]` | 1.016 ms (5%) | | 320.23 KiB (1%) | 5 | | `["error diffusion", "color inplace"]` | 143.166 ms (5%) | | 16.01 MiB (1%) | 995660 | | `["error diffusion", "color new"]` | 133.922 ms (5%) | | 16.01 MiB (1%) | 995660 | | `["error diffusion", "per-channel inplace"]` | 3.876 ms (5%) | | 960.42 KiB (1%) | 11 | | `["error diffusion", "per-channel new"]` | 4.202 ms (5%) | | 960.42 KiB (1%) | 11 | | `["ordered dithering", "binary inplace"]` | 96.802 μs (5%) | | 69.42 KiB (1%) | 5 | | `["ordered dithering", "binary new"]` | 91.902 μs (5%) | | 69.42 KiB (1%) | 5 | | `["ordered dithering", "color inplace"]` | 704.037 ms (5%) | 11.638 ms | 247.07 MiB (1%) | 14417965 | | `["ordered dithering", "color new"]` | 852.045 ms (5%) | 15.808 ms | 281.11 MiB (1%) | 16473466 | | `["ordered dithering", "per-channel inplace"]` | 1.035 ms (5%) | | 207.98 KiB (1%) | 11 | | `["ordered dithering", "per-channel new"]` | 1.097 ms (5%) | | 207.98 KiB (1%) | 11 | | `["threshold dithering", "binary inplace"]` | 11.800 μs (5%) | | 128.27 KiB (1%) | 7 | | `["threshold dithering", "binary new"]` | 10.100 μs (5%) | | 128.27 KiB (1%) | 7 | | `["threshold dithering", "per-channel inplace"]` | 1.004 ms (5%) | | 384.38 KiB (1%) | 8 | | `["threshold dithering", "per-channel new"]` | 1.057 ms (5%) | | 384.38 KiB (1%) | 8 | ## Benchmark Group List Here's a list of all the benchmark groups executed by this job: - `["closest color"]` - `["error diffusion"]` - `["ordered dithering"]` - `["threshold dithering"]` ## Julia versioninfo ``` Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) Ubuntu 20.04.4 LTS uname: Linux 5.13.0-1022-azure #26~20.04.1-Ubuntu SMP Thu Apr 7 19:42:45 UTC 2022 x86_64 x86_64 CPU: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz: speed user nice sys idle irq #1 2095 MHz 2441 s 2 s 178 s 2530 s 0 s #2 2095 MHz 2738 s 1 s 192 s 2235 s 0 s Memory: 6.783603668212891 GB (3775.87890625 MB free) Uptime: 521.17 sec Load Avg: 1.0 0.9 0.5 WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512) ``` --- # Runtime information | Runtime Info | | |:--|:--| | BLAS #threads | 2 | | `BLAS.vendor()` | `openblas64` | | `Sys.CPU_THREADS` | 2 | `lscpu` output: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz Stepping: 4 CPU MHz: 2095.077 BogoMIPS: 4190.15 Hypervisor vendor: Microsoft Virtualization type: full L1d cache: 64 KiB L1i cache: 64 KiB L2 cache: 2 MiB L3 cache: 35.8 MiB 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 Spec store bypass: Vulnerable Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT Host state unknown 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 mpx avx512f avx512dq rdseed adx smap clflushopt avx512cd avx512bw avx512vl xsaveopt xsavec xsaves md_clear | Cpu Property | Value | |:------------------ |:------------------------------------------------------- | | Brand | Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz | | Vendor | :Intel | | Architecture | :Skylake | | Model | Family: 0x06, Model: 0x55, Stepping: 0x04, 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 |
johnnychen94 commented 2 years ago

I'm surprised that this actually makes things slower...

Edit:

This might be implementation-specific; if the filter weights are StaticMatrix then the performance regression here can be eliminated. I'll try to rework the error diffusion dither implementation on top of this PR and see if we get better results.

adrhill commented 2 years ago

This might be implementation-specific; if the filter weights are StaticMatrix then the performance regression here can be eliminated. I'll try to rework the error diffusion dither implementation on top of this PR and see if we get better results.

I've had some shower-thoughts about this. I think we should fully drop the dependency on OffsetArrays and use CartesianIndices to iterate over the neighborhoods defined in the filters. This might also simplify a future implementation of #20.

adrhill commented 2 years ago

Closing this as it is outdated by #73 , which contains parts of this PR.