TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Scipio: A Thread-per-Core Crate for Rust and Linux

167 pointsby akshaykumar90over 4 years ago

11 comments

Luker88over 4 years ago
I am a fan of the thread-per-core model, but I do not share their views on the data sharding per core<p>While it increases the data locality, I have seen a few software following this sharding model (notably scylla) that work really bad once the load is not evenly distributed across all shards<p>When that happens it can be a huge waste of resources and can give lower performance (depending on the type of load)<p>Imho unless you are absolutely sure about the type of load, leave the sharding to dividing data between servers, or have some mechanism that can shift to sharing the load between threads if the system imbalance is too great
评论 #24980493 未加载
评论 #24980907 未加载
评论 #24984566 未加载
BenoitPover 4 years ago
I&#x27;ll go against the grain here and say that async&#x2F;await, wether implemented by one thread-per-core like here or by stackless coroutines is not the solution.<p>Async&#x2F;await will make complexity explode because of the colored function problem [1].<p>The solution to expensive context switches is cheap context switches, plain and simple. User-mode lightweight threads like go&#x27;s, or upcoming Java&#x27;s with Loom [2] have proven that this is possible.<p>Yes, it does mean that it can only happen in a language that controls its stack (so that you can slice it off and pop a continuation on it). I sincerely believe this is Rust&#x27;s ballpark; hell they even started the project with that idea in mind.<p>[1] <a href="https:&#x2F;&#x2F;journal.stuffwithstuff.com&#x2F;2015&#x2F;02&#x2F;01&#x2F;what-color-is-your-function&#x2F;" rel="nofollow">https:&#x2F;&#x2F;journal.stuffwithstuff.com&#x2F;2015&#x2F;02&#x2F;01&#x2F;what-color-is-...</a><p>[2] <a href="https:&#x2F;&#x2F;jdk.java.net&#x2F;loom&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jdk.java.net&#x2F;loom&#x2F;</a>
评论 #24979693 未加载
评论 #24979359 未加载
评论 #24979389 未加载
评论 #24981487 未加载
评论 #24980406 未加载
评论 #24979306 未加载
评论 #24979348 未加载
评论 #24979655 未加载
评论 #24979209 未加载
评论 #24980620 未加载
评论 #24979534 未加载
评论 #24979560 未加载
评论 #24982165 未加载
MrBuddyCasinoover 4 years ago
Finally, a Seastar clone for Rust! Really impressed by some of the work coming out from Datadog. Curious if one of the popular Rust web frameworks will choose it as I&#x2F;O backend, could be a great way to push down latencies even further.
评论 #24979570 未加载
rwhaover 4 years ago
With a name like Scipio I would imagine it also uses a thread-per-core of neighboring computers as well.
faitswulffover 4 years ago
Scipio has seen some action on HN before in &quot;C++ vs Rust: an async Thread-per-Core story&quot;: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24444347" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24444347</a>
Cloudefover 4 years ago
Why not use multiple processes instead?
评论 #24978636 未加载
评论 #24978330 未加载
评论 #24978215 未加载
shwestrickover 4 years ago
Thread-per-core has been around for a while! It&#x27;s how a lot of modern multicore languages work. You&#x27;ve probably heard of &quot;green&quot; or &quot;lightweight&quot; threads before... it&#x27;s all the same idea. Typically, you&#x27;d want to use a scheduler (probably work-stealing <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Work_stealing" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Work_stealing</a>) under the hood to dynamically assign tasks to processors, which is much more effective at load-balancing than &quot;sharding&quot;.<p>All of these languages&#x2F;libraries use a dynamic scheduler for load-balancing:<p>* Rayon (Rust) [<a href="https:&#x2F;&#x2F;github.com&#x2F;rayon-rs&#x2F;rayon" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rayon-rs&#x2F;rayon</a>]<p>* Goroutines (Go) [<a href="https:&#x2F;&#x2F;golangbyexample.com&#x2F;goroutines-golang&#x2F;" rel="nofollow">https:&#x2F;&#x2F;golangbyexample.com&#x2F;goroutines-golang&#x2F;</a>]<p>* OpenMP [<a href="https:&#x2F;&#x2F;www.openmp.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.openmp.org&#x2F;</a>]<p>* Task Parallel Library (.NET) [<a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;standard&#x2F;parallel-programming&#x2F;task-parallel-library-tpl" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;standard&#x2F;parallel-pr...</a>]<p>* Thread Building Blocks (C++) [<a href="https:&#x2F;&#x2F;software.intel.com&#x2F;content&#x2F;www&#x2F;us&#x2F;en&#x2F;develop&#x2F;tools&#x2F;threading-building-blocks.html" rel="nofollow">https:&#x2F;&#x2F;software.intel.com&#x2F;content&#x2F;www&#x2F;us&#x2F;en&#x2F;develop&#x2F;tools&#x2F;t...</a>]<p>* Cilk (C&#x2F;C++) [<a href="http:&#x2F;&#x2F;cilk.mit.edu&#x2F;" rel="nofollow">http:&#x2F;&#x2F;cilk.mit.edu&#x2F;</a>]<p>* Java Fork-Join and Parallel Streams [<a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;collections&#x2F;streams&#x2F;parallelism.html" rel="nofollow">https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;collections&#x2F;streams&#x2F;...</a>]<p>* ParlayLib (C++) [<a href="https:&#x2F;&#x2F;github.com&#x2F;cmuparlay&#x2F;parlaylib" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cmuparlay&#x2F;parlaylib</a>]
评论 #24980570 未加载
di4naover 4 years ago
So this sounds a lot like an application of Virding&#x27;s First Rule of Programming.<p><i>Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.</i><p><a href="http:&#x2F;&#x2F;rvirding.blogspot.com&#x2F;2008&#x2F;01&#x2F;virdings-first-rule-of-programming.html" rel="nofollow">http:&#x2F;&#x2F;rvirding.blogspot.com&#x2F;2008&#x2F;01&#x2F;virdings-first-rule-of-...</a>
评论 #24978924 未加载
lomkjuover 4 years ago
This only makes sense if the local I&#x2F;O is really fast and in many cases you contact external databases where the context switches are negligible to the I&#x2F;O time spent on a query.
评论 #24984221 未加载
Horusiathover 4 years ago
Can we make it work in Windows by any chance?
评论 #24978962 未加载
评论 #24978986 未加载
评论 #24977990 未加载
评论 #24977708 未加载
评论 #24977656 未加载
indyover 4 years ago
Would a thread-per-core architecture help mitigate security vulnerabilities like spectre and meltdown?
评论 #24981702 未加载
评论 #24977989 未加载
评论 #24979441 未加载