# OpenBLAS threads repeatedly call gettimeofday() at the end of a loop

**URL:** <https://discourse.julialang.org/t/openblas-threads-repeatedly-call-gettimeofday-at-the-end-of-a-loop/84027>\
**Category:** Performance\
**Created:** [July 11, 2022, 12:52am UTC](https://discourse.julialang.org/t/openblas-threads-repeatedly-call-gettimeofday-at-the-end-of-a-loop/84027 "2022-07-11T00:52:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxwindiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@maxwindiff](https://discourse.julialang.org/u/maxwindiff)\
**Post date:** [July 11, 2022, 12:52am UTC](https://discourse.julialang.org/t/openblas-threads-repeatedly-call-gettimeofday-at-the-end-of-a-loop/84027/1 "2022-07-11T00:52:52Z")

</div>

When doing some profiling, I noticed that OpenBLAS threads would make a lot of calls to gettimeofday(), usually at the end of a loop. It happens on both Julia 1.7 and 1.8-rc1. In some of my programs this can add up to 10-20% of the total time spent by a thread. Any idea what’s causing this?

```julia
N = 2048
a = rand(Float32, N, N)
b = rand(Float32, N, N)
for i = 1:100
  a*b
end

```

 ![Screen Shot 2022-07-10 at 17.40.59](https://global.discourse-cdn.com/julialang/original/3X/7/2/7238572aff393cd14563ac7f64ec81fd692a0470.png)

I’m running the ARM builds on an M1 MacBook Pro.

```julia
julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libopenblas64_.dylib

julia> versioninfo()
Julia Version 1.8.0-rc1
Commit 6368fdc6565 (2022-05-27 18:33 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores

```
