Skip to content

imfilter huge perf drop when  #161

@wizebt

Description

@wizebt

imfilter use for gaussian filter in my astro image processing becomes randomly ~10x slower. The following test function can reproduce the issue. At this stage I'm not able to investigate further nor understand the root cause. can you please help. Thanks

Test environment, same behavior in 1.3 or 1.3.1. or on different machine

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4940MX CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
Environment:
  JULIA_NUM_THREADS = 4
function test_imfilter()
	gk = Kernel.gaussian(2.0f0)
	I = rand(Float32,1000,2000)
	
	for i = 1:9
		start = time()
		J = Images.imfilter(I,gk)
		t = round(time() - start, digits=6)
		t > 1 && println("$i imfilter $t sec")
	end
end

Now testing, nothing else was running on the laptop

julia> include("test_imfilter.jl")
f! (generic function with 1 method)

julia> using BenchmarkTools

julia> @benchmark test_imfilter()
BenchmarkTools.Trial: 
  memory estimate:  147.52 MiB
  allocs estimate:  23748
  --------------
  minimum time:     177.292 ms (1.07% GC)
  median time:      183.574 ms (1.07% GC)
  mean time:        190.164 ms (4.57% GC)
  maximum time:     289.147 ms (37.44% GC)
  --------------
  samples:          27
  evals/sample:     1

Even with lots of GC, ~0.3 sec
When use in conjunction with ImageView or Gtk package, perf drop 10 to 20x even with little GC

julia> using ImageView
Gtk-Message: 21:35:38.199: Failed to load module "canberra-gtk-module"
Gtk-Message: 21:35:38.200: Failed to load module "canberra-gtk-module"

julia> @benchmark test_imfilter()
1 imfilter 5.023953 sec
3 imfilter 5.037526 sec
1 imfilter 5.023682 sec
2 imfilter 5.031469 sec
3 imfilter 5.029917 sec
4 imfilter 5.030758 sec
6 imfilter 5.020171 sec
8 imfilter 4.395933 sec
1 imfilter 5.022895 sec
2 imfilter 5.026384 sec
3 imfilter 5.030159 sec
5 imfilter 5.023577 sec
7 imfilter 5.02138 sec
1 imfilter 5.023868 sec
5 imfilter 5.023962 sec
BenchmarkTools.Trial: 
  memory estimate:  147.52 MiB
  allocs estimate:  23851
  --------------
  minimum time:     10.196 s (0.02% GC)
  median time:      10.196 s (0.02% GC)
  mean time:        10.196 s (0.02% GC)
  maximum time:     10.196 s (0.02% GC)
  --------------
  samples:          1
  evals/sample:     1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions