Repository navigation
Fix compilation slowdown due to controlflow analysis - #6146
Conversation
|
My current reproducer for issue #6133 from pprint import pprint
import numpy as np
import numba
body = """
for fi in range(0, 10):
data[fi] += 1
for index in range(0, 7):
idx = index
if idx % 2 == 0:
data[idx] += fi
else:
data[idx] += 1 if data[idx] < 3 else 2
data[idx] += 1
data[idx] += 1
"""
wrapper = """
def kernel(data):
{}
"""
source = wrapper.format(body * 100) # 75
glbs = {}
exec(source, glbs)
arg = np.zeros(100)
argtypes = (numba.typeof(arg),)
kernel = numba.njit(argtypes)(glbs['kernel'])
# 0.48.0 takes 24sec
# 0.51.0 takes 1min13sec
metadata = kernel.get_metadata(kernel.signatures[0])
timings = metadata['pipeline_times']['nopython']
sorttimings = sorted(timings.items(), key=lambda x: sum(x[1]))
for k, v in reversed(sorttimings):
print(f"{k:40} {sum(v):.3}")This prints the compiler passes in descending runtime. With the patch: Without the patch: So the patch trims 20 seconds from SSA |
Note: dominator-based version is too expensive.
|
264665e replaces the backedge algorithm with a simple but faster DFS version. This further speed up the SSA reconstruction: (updated to use output from non-profiled run) |
|
Thanks for the patch. I tested this manually, locally, 10.4->4.73s change in SSA rebuild. |
stuartarchibald
left a comment
There was a problem hiding this comment.
Code changes look good, couple of minor comments.
| # A few derived items are checked to makes sure process() has been | ||
| # invoked equally. |
There was a problem hiding this comment.
Can probably remove this comment now, process() has little effect as everything is delayed.
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
|
Resolved all comments. |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the fixes.
Fix compilation slowdown due to controlflow analysis
Uh oh!
There was an error while loading. Please reload this page.