Skip to content

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Nov 15, 2022

Or should it be typedthreads or thread_v1? I don't know. Suggestions are appreciated.

@PMunch
Copy link
Contributor

PMunch commented Nov 15, 2022

Depends on what the new module is going to be called, and what the relationship between them is going to be. The threads module is a fairly thin wrapper over the system threads, how is this going to change with the new threads? Are people still going to use the old threads module if they want this low-level access?

@arnetheduck
Copy link
Contributor

why is it being changed?

@ringabout
Copy link
Member Author

The implementation of std/threads is not good enough. In 2.x, there will be likely to have a better std/threads module. In case of the name conflicts, it needs to be renamed.

@ringabout
Copy link
Member Author

ringabout commented Nov 15, 2022

how is this going to change with the new threads? Are people still going to use the old threads module if they want this low-level access?

The new std/threads is likely to have bare primitives and no generics. It should be simply a thin wrapper of system threads while it's not true for the current implementation which stores thread local data and the callback pair.

@arnetheduck
Copy link
Contributor

Developing a new thread module sounds like something that will be a compromise between rushing a poor thread module and delaying v2 - why not leave a new thread module to 2.2? Creating one is not part of v2 goals really.

@ringabout
Copy link
Member Author

Developing a new thread module sounds like something that will be a compromise between rushing a poor thread module and delaying v2 - why not leave a new thread module to 2.2? Creating one is not part of v2 goals really.

In 2.x, there will be likely to have a better std/threads module.

Perhaps I was not clear. As I said, there is no plan for a new std/threads module in v2 release. It will be implemented in 2.x.

@ringabout ringabout changed the title rename std/threads to std/oldthreads rename std/threads to std/typedthreads Nov 15, 2022
@PMunch
Copy link
Contributor

PMunch commented Nov 15, 2022

I don't think it's a great look for Nim v2 to have soft deprecated our threads module with no alternative.. I find this a very strange decision, especially considering how --threads:on will become the default and ARC/ORC promises easier multithreading.

@arnetheduck
Copy link
Contributor

I don't think it's a great look

"It will be shipped in 2.2" is an excellent answer to that comment - ie it's perfectly fine, given that nothing was really lost (ie the current threads module is hardly worth bragging about and DIY threading is kind of the norm since none of abstactions work well - the idea with --threads:on is to make sure that the core language parts don't fall apart under DIY threading conditions at least.

@PMunch
Copy link
Contributor

PMunch commented Nov 15, 2022

I was more thinking about the publicity spike that Nim will get a v2 release. It will look like Nim v1 had threading but v2 removed it. I'm just saying that it would look a bit odd, even if the old threading module wasn't anything to write home about. In a perfect world I would of course like Nim v2 to ship with a new and improved story for multithreading, but by the look of things that would delay the launch quite significantly (although maybe it would be more deserving of the v2 name).

@Varriount
Copy link
Contributor

I feel that it would be better to deprecate the current "thread" module only when we have a viable replacement. This avoids pressure to release a sub-par alternative because "we need a replacement ASAP".

@Araq
Copy link
Member

Araq commented Nov 16, 2022

Let me clear up the situation: The threading primitives moved out of system.nim for nimPreviewSlimSystem. There was no std / threads before so nothing got removed. We're bikeshedding about a name, that's all. And ideally the new name doesn't prevent us from coming with an even better threads module later so typedthreads is a good solution.

@PMunch
Copy link
Contributor

PMunch commented Nov 16, 2022

So this module will still be automatically imported when --threads:on? The new typedthreads name is definitely much better, when I started commenting it was called oldthreads which made it appear like we didn't have a new solution for threads.

@ringabout
Copy link
Member Author

So this module will still be automatically imported when --threads:on?

Yeah. It is imported by default (without -d:nimPreviewSlimSystem).

@Araq Araq merged commit e03a178 into devel Nov 16, 2022
@Araq Araq deleted the pr_old_threads branch November 16, 2022 15:35
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from e03a178

Hint: mm: orc; opt: speed; options: -d:release
165126 lines; 8.129s; 614.172MiB peakmem

@arnetheduck
Copy link
Contributor

so hold on - if this is imported automatically and not meant to be a "user" import, why is it in the std namespace?

@ringabout
Copy link
Member Author

ringabout commented Nov 16, 2022

Because it is not imported with -d:nimPreviewSlimSystem. Users' code should still work with -d:nimPreviewSlimSystem by simply importing a module. Perhaps we can give an error when users try to import these modules without -d:nimPreviewSlimSystem.

capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
* rename `std/threads` to `std/oldthreads`

* fixes tests

* rename to `typedthreads`

* changelog
bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
* rename `std/threads` to `std/oldthreads`

* fixes tests

* rename to `typedthreads`

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants