[{"data":1,"prerenderedAt":74},["ShallowReactive",2],{"term-l\u002Flock-contention":3,"related-l\u002Flock-contention":59},{"id":4,"title":5,"acronym":6,"body":7,"category":40,"description":41,"difficulty":42,"extension":43,"letter":44,"meta":45,"navigation":46,"path":47,"related":48,"seo":53,"sitemap":54,"stem":57,"subcategory":6,"__hash__":58},"terms\u002Fterms\u002Fl\u002Flock-contention.md","Lock Contention",null,{"type":8,"value":9,"toc":33},"minimark",[10,15,19,23,26,30],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"Lock contention is what happens when a mutex becomes the most popular door in the building, and instead of doing useful work, half your threads are just standing in line waiting for it to open. Adding more threads doesn't help anymore, it just makes the line longer, which is why just add more threads stops working the moment everything funnels through one lock.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Lock contention occurs when multiple threads frequently attempt to acquire the same lock at the same time, forcing most of them to block and wait rather than execute in parallel. High contention on a single lock caps the effective parallelism of a system regardless of how many CPU cores are available, and is typically fixed by sharding the lock, using finer-grained locks, or switching to a lock-free data structure.",[11,27,29],{"id":28},"when-youll-hear-this","When You'll Hear This",[16,31,32],{},"\"We sharded the single global lock into sixteen and contention basically vanished.\" \u002F \"Profiling showed threads spending 80% of their time waiting on one mutex.\"",{"title":34,"searchDepth":35,"depth":35,"links":36},"",2,[37,38,39],{"id":13,"depth":35,"text":14},{"id":21,"depth":35,"text":22},{"id":28,"depth":35,"text":29},"backend","Lock contention is what happens when a mutex becomes the most popular door in the building, and instead of doing useful work, half your threads are just st...","intermediate","md","l",{},true,"\u002Fterms\u002Fl\u002Flock-contention",[49,50,51,52],"Mutex","Lock-Free","Work Stealing","Perf Counters",{"title":5,"description":41},{"changefreq":55,"priority":56},"weekly",0.7,"terms\u002Fl\u002Flock-contention","BAPFBOUiZq80_m4Iv7-iysRIYN8JbApkey3mtzfjvUg",[60,64,67,70],{"title":50,"path":61,"acronym":6,"category":40,"difficulty":62,"description":63},"\u002Fterms\u002Fl\u002Flock-free","advanced","Lock-free code gets multiple threads to safely share data without ever making anyone stand in line waiting for a lock.",{"title":49,"path":65,"acronym":6,"category":40,"difficulty":42,"description":66},"\u002Fterms\u002Fm\u002Fmutex","A mutex is a single key to a single bathroom.",{"title":52,"path":68,"acronym":6,"category":40,"difficulty":62,"description":69},"\u002Fterms\u002Fp\u002Fperf-counters","Perf counters are the CPU's own built-in scorekeepers, tiny hardware registers that silently count things like cache misses, branch mispredictions, and ins...",{"title":51,"path":71,"acronym":6,"category":72,"difficulty":62,"description":73},"\u002Fterms\u002Fw\u002Fwork-stealing","architecture","Work stealing is how a pool of worker threads keeps itself busy without a manager micromanaging every task.",1792528097290]