# @time reporting lock conflicts - what are these?

**URL:** <https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 14, 2024, 5:17pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300 "2024-10-14T17:17:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [October 14, 2024, 5:17pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/1 "2024-10-14T17:17:19Z")

</div>

When I use `@time` to time a particular function that reads and write from/to several large files, the output shows (for example):

```julia
0.403770 seconds (6.20 k allocations: 233.059 MiB, 8.12% gc time, 4 lock conflicts

```

I’ve never seen these lock conflicts reported before. Are they new in v1.11? What do they mean?

My code isn’t generating any other errors and, on the face of it, seems to be working. Are these lock conflicts important, can I ignore them, or do I need to eliminate them?

Thanks!

---

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [October 14, 2024, 6:00pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/2 "2024-10-14T18:00:40Z")

</div>

It seems the line that is giving rise to these lock conflicts says this:

```julia
@time arrowTable = Arrow.Table(arrowfile)

```

It is called five times on 5 different files in one iteration. This generates (for example):

```julia
  0.000567 seconds (719 allocations: 34.938 KiB)
  0.000425 seconds (209 allocations: 12.234 KiB, 1 lock conflict)
  0.000492 seconds (218 allocations: 12.781 KiB, 1 lock conflict)
  0.000516 seconds (232 allocations: 13.188 KiB, 1 lock conflict)
  0.000417 seconds (220 allocations: 12.859 KiB, 2 lock conflicts)

```

So it seems that this is outside my control and probably unimportant (although “lock conflicts” sound like they should be important!)

I found [this](https://julialang.org/blog/2024/10/julia-1.11-highlights/#the_time_macro_now_reports_lock_conflicts), which I probably should have found before posting.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 14, 2024, 6:12pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/3 "2024-10-14T18:12:29Z")

</div>

Lock conflicts are when 2 different locations try to take the same lock at the same time (causing one to have to wait until the other is done). In this case, the lock is likely one in the IO system.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 14, 2024, 7:39pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/4 "2024-10-14T19:39:40Z")

</div>

> [@TimG](#):
>
> So it seems that this is outside my control

The `open` function takes a `lock` keyword argument. Setting `lock = false` will disable locking. If you’re not doing concurrent IO, I suppose you could safely turn off locking.

> [@Oscar\_Smith](#):
>
> 2 different locations try to take the same lock at the same time (causing one to have to wait until the other is done)

Also known as _lock contention_.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [October 14, 2024, 7:51pm UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/5 "2024-10-14T19:51:44Z")

</div>

> [@TimG](#):
>
> My code isn’t generating any other errors and, on the face of it, seems to be working. Are these lock conflicts important, can I ignore them, or do I need to eliminate them?

Your code is fine. Like the other metrics reported by `@time`, lock conflicts can be problematic for performance, but not for correctness. Your code is successfully doing what you asked it to do.

Don’t try to eliminate them unless you know what you’re doing. _That_ could lead to correctness issues.

---

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [October 16, 2024, 7:29am UTC](https://discourse.julialang.org/t/time-reporting-lock-conflicts-what-are-these/121300/6 "2024-10-16T07:29:22Z")

</div>

Thank you for these replies.

The conflicts I’m seeing all seem to be arising from Arrow.jl and so I’m not going to try to resolve them. As I say, there is no other sign of trouble in my case.
