I was wondering where does this parallelism level come from? Seems like some internal runtime value?
So far when testing it seemed to always be set to 1 for me. Is there any way to configure this?
@always_inline
fn parallelism_level() -> Int:
"""Gets the parallelism level of the Runtime.
Returns:
The number of worker threads available in the async runtime.
"""
return Int(
external_call[
"KGEN_CompilerRT_AsyncRT_ParallelismLevel",
Int32,
]()
)
This is not a value that can be set externally right now. It is used differently in different contexts. During Mojo compilation, for example, the Mojo compiler uses it to determine how many threads it can use. In that case, it should be set to the number of CPUs on the host.
Is there a specific use case you have in mind for this value?
I wanted to try adding some basic async support to my http library, Lightbug. Can’t seem to figure out how to spawn threads with pthread without a C wrapper, so I thought I’d try this out for async. But looks like I can only do things sequentially now? Or am I missing something. Owen also mentioned that this might not be a good time to depend on this Async functionality for real world applications
Yeah, I would avoid using asyncrt for this kind of async programming now. I think we want to build a better async programming model into Mojo. The asyncrt library is mostly for internal use now, and likely not what you want for this case.
Hi all. While async is an important part of the Mojo language the team is focused on other issues at this time. We do not yet have a release date for async, but it is on our roadmap.