fasterthanlime , Englisch
@fasterthanlime@hachyderm.io avatar

Found another snag re: dynamic linking Rust code — N copies of tokio are present, so that's N distinct thread-locals storing the "current tokio context"

...and the binary is calling the library from an executor, but the library doesn't think so.

https://github.com/tokio-rs/tokio/blob/65d0e08d39f06eba88661d3d6de665b14588f30d/tokio/src/runtime/context.rs#L77-L122

unsaturated ,
@unsaturated@discuss.systems avatar

@fasterthanlime simple: Operating system written in Rust running in hardware designed for Rust with ABI molded to exactly fit Rust and Rust Package Model is fundamental to the stack, all software in Rust and Rust only runs here. :done:

noah ,
@noah@mastodon.despise.computer avatar

@fasterthanlime honestly i kinda wonder if we should just expose a --cfg flag for "just make this work across SO boundaries"

even if it slightly changes some semantics or has a perf cost when enabled, that's fine - it's behind a --cfg flag

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@noah having gone through other unsuccessful paths right now: how would you even make that work?

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@noah pthread_key_create?

noah ,
@noah@mastodon.despise.computer avatar

@fasterthanlime i have put zero thought into how this might work thus far

if you can make this work though that would be amazing

groxx ,
@groxx@hachyderm.io avatar

@fasterthanlime I continue to grow ever more convinced that globals are the original programming sin (not nulls). Thread locals are just spicy globals, and they cause all the same problems...

bjorn3 ,
@bjorn3@hachyderm.io avatar

@fasterthanlime You can make a dylib which depends on tokio and then depend on this dylib from all your other dylibs to ensure only a single copy of tokio is present. Make sure to use use foo as _; or something similar to male rustc actually register a dependency on foo. Just having it in your Cargo.toml is not enough.

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

Well, it’s nothing nested tokio runtimes cannot fix 🤡

cjk ,
@cjk@chaos.social avatar

@fasterthanlime I once wrote a task runner library with different queues and priorities and all the bells and whistles.

I spawned a tokio runtime for every queue, with a configurable amount of workers.

Oh boy, did I regret that. 🫣

d2718 ,
@d2718@hachyderm.io avatar

@fasterthanlime OMG, "nested tokio runtimes" is definitely a candidate for "below the waterline" in that iceberg-of-programming image.

yshui ,
@yshui@fosstodon.org avatar

@fasterthanlime I have seen this problem so many times 😖 and it's super hard and confusing to debug too.

piecritic ,
@piecritic@hachyderm.io avatar

@fasterthanlime i for one welcome my several thread local overlords

  • Alle
  • Abonniert
  • Moderiert
  • Favoriten
  • random
  • haupteingang
  • Alle Magazine