Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upintegration needs thread discovery (even for e.g. `#[test]`) #2
Comments
This comment has been minimized.
This comment has been minimized.
|
That's pretty unfortunate - the collector does expect every thread that uses the allocator to call I wonder, is there any precedent for languages allowing you to attach callbacks for when a thread has been spawned? I suppose we could call one here that's been set globally? I imagine that would impact the performance of spawning threads. I don't tinker much with Rust internals but I'd imagine that would add a static read and a null check as a part of the hot path of thread creation, though it pales in comparison to the cost of creating the thread itself. Also, the collector requires the program to either call Also, the second abort that you discovered happened here - maybe you'll fiddle with the defines and rebuild for it to not abort. Another +1 for compiling libgc for ourselves? |
This comment has been minimized.
This comment has been minimized.
|
@swgillespie I spent some time today hacking up exactly what you describe: I added a callback registration system invoked on every thread start. I don't think the overhead will be too high (at least for someone who isn't using the callbacks -- i.e., our standard "zero cost" goal). With that in place, and overriding the test driver harness to call my own I'll talk to the libs team about how feasible it might be to add such a callback system. |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix Cool, that's really awesome!! I look forward to hearing what the libs team has to say, it would be really exciting to get this fully working! I suppose that in the event of the libs team rejecting this sort of thing, we could either 1) provide an alternative thread-spawning API that registers the thread upon creation, while requiring users to call Both of those have the major downside that they break any code that spawns a thread and allocates immediately afterward, like the test harness, but I guess if you're swapping out the allocator you run the risk of bad things? I don't like it, but maybe there's no other option - |
pnkfelix
referenced this issue
Nov 7, 2015
Open
build script; OS X + brew does not put libgc.a on OS linker path; extend it #1
This comment has been minimized.
This comment has been minimized.
|
linking relevant conversation: https://internals.rust-lang.org/t/rfrfc-std-thread-at-start-callback/2877/18 |
pnkfelix commentedNov 5, 2015
Consider the following crate source code (small enough for inclusion in
tests/smoketest.rs):cargo teston this fails on the first collection cycle and aborts the process.The relevant piece of information here, I think, is
Collecting from unknown thread.I believe every spawned thread needs to be registered with the Boehm collector.
There is deprecated functionality to automatically discover the spawned threads, but:
mod sys;and calling it, I got a new abort on OS X, with the messageDarwin task-threads-based stop and push unsupported. I have not yet investigated this.Ideally we would just register the threads as they are created, but I do not think the Rust runtime today has a mechanism for registering a callback to accomplish this.