question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

performance issue with F-order array

See original GitHub issue

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.

run once before the test to make sure it’s compiled:

@njit
def foo(a, b):
    return a * b

a = np.random.randn(8192, 2592)
b = np.copy(a)
%%timeit -n 10
_ = foo(a, b)
# 83.7 ms ± 1.67 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit -n 10
_ = foo.py_func(a, b)
# 29.6 ms ± 558 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
af, bf = map(np.asfortranarray, (a, b))
%%time
_ = foo(af, bf)
# CPU times: user 1.75 s, sys: 54.6 ms, total: 1.8 s
# Wall time: 1.74 s
%%timeit -n 10
_ = foo.py_func(af, bf)
# 30.8 ms ± 420 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

We can observe a significant slow down with F-order array compared to pure numpy codes. BTW, even original C-order version is slower too.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
audersoncommented, Nov 10, 2022

I tested with 0.56.3. I’ve not tested with older versions.

0reactions
apmasellcommented, Nov 15, 2022

Once the PR is merged, either F or C will be fine, but mixed will always be slower.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a performance impact when calling ToList()?
When calling on an array, list, or other collection, you create a copy of the collection as a List<T> . The performance here...
Read more >
Looking for performance? Probably you should NOT use [].sort ...
You can test speed by sorting bigger and bigger array, stop, if suma of times bigger than limit. In my code is quick...
Read more >
Find and sort has poor performance · Issue #645 - GitHub
Each operation by itself is very fast. I can run a simplesort() or find() the whole collection in 1ms each, but if I...
Read more >
How to speed up Array's Sorting in Swift - Eltima
But if the files are sorted like in the Finder, performance drops dramatically in case array contains a big amount of elements.
Read more >
10 Most Common Mistakes That PHP Developers Make - Toptal
Common Mistake #1: Leaving dangling array references after foreach loops ... The problem is that, if you're not careful, this can also have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found