# Yet Another Performance Footgun in Rust - Multithreading Lock Edition

**URL:** <https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726>\
**Category:** language design\
**Created:** [October 30, 2026, 2:51am UTC](https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726 "2026-10-30T02:51:50Z")\
**Posts on this page:** 1\
**Showing post:** 40

<div class="post-metadata">

**Author:** ![mathstuf](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mathstuf](https://internals.rust-lang.org/u/mathstuf)\
**Post date:** [November 3, 2026, 12:24pm UTC](https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726/40 "2026-11-03T12:24:30Z")

</div>

> [@ProgramCrafter](#):
>
> In practice, i.e. code I saw and code I wrote, either the closing bracket _is_ after `data.update`, or the mutex **should've** been held until later.

I have a case where I didn't want the lock held for the entire scope. However, even then, the solution is not early drop because the issue caused by holding the lock for too long was solved by using existing Rust facilities to make sure it _never_ happens again rather than "getting lucky" with the ASAP drop mechanism that could have allowed the bad pattern to be written again in the future.

See [this old post](https://internals.rust-lang.org/t/idea-experimental-attribute-based-support-for-partial-borrows/20744/29), but the changes are in [this MR](https://gitlab.kitware.com/utils/ghostflow-director/-/merge_requests/357). [This commit](https://gitlab.kitware.com/utils/ghostflow-director/-/merge_requests/357/diffs?commit_id=974a3833801784506232c79239be98f577e7c07e) is the "ASAP drop" fix. but [this followup commit](https://gitlab.kitware.com/utils/ghostflow-director/-/merge_requests/357/diffs?commit_id=f6eb477ca2e8f0f6a34f97dfdfadf71ee7a67011) is the "never allow it to happen again" fix where the compiler ensures that it never happens again. While ASAP drop would have avoided this bug in some of the methods (member borrowing would likely have extended the lock in various cases; `Copy` in others avoiding the bug), I think I'm happier with the compiler-enforced mechanism that now exists instead.

---

_[View the full topic](https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726)._
