Dmitry Salin
Dmitry Salin
MModular
Created by lukas on 5/11/2024 in #community-showcase
tree-sitter-mojo
There was a bug with LSP in the old Mojo nightlies, but it has been fixed. https://github.com/modularml/mojo/issues/2835 I use most recent Mojo nightly build.
58 replies
MModular
Created by lukas on 5/11/2024 in #community-showcase
tree-sitter-mojo
I'm trying these binaries https://github.com/helix-editor/helix/releases/tag/24.07 And on Linux everything works fine. My log:
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "I[18:08:50.071] --> initialize(0)\n"
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "I[18:08:50.071] --> reply:initialize(0)\n"
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "D[18:08:50.071] >>> {\"id\":0,\"jsonrpc\":\"2.0\",\"result\":{\"capabilities\":{\"codeActionProvider\":{\"codeActionKinds\":[\"quickfix\",\"refactor\",\"info\"]},\"completionProvider\":{\"allCommitCharacters\":[\"\\t\"],\"resolveProvider\":false,\"triggerCharacters\":[\".\"]},\"definitionProvider\":true,\"documentSymbolProvider\":false,\"foldingRangeProvider\":true,\"hoverProvider\":true,\"inlayHintProvider\":true,\"notebookDocumentSync\":{\"notebookSelector\":[{\"cells\":[{\"language\":\"mojo\"}],\"notebook\":{\"notebookType\":\"jupyter-notebook\",\"scheme\":\"file\"}}]},\"referencesProvider\":true,\"renameProvider\":true,\"semanticTokensProvider\":{\"full\":{\"delta\":true},\"legend\":{\"tokenModifiers\":[],\"tokenTypes\":[\"variable\",\"specialVariable\",\"parameter\",\"function\",\"method\",\"property\",\"class\",\"interface\",\"type\",\"namespace\"]},\"range\":false},\"signatureHelpProvider\":{\"triggerCharacters\":[\"(\",\"[\",\",\"]},\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":true}},\"serverInfo\":{\"name\":\"mojo-lsp-server\",\"version\":\"0.0.1\"}}}\n"
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "I[18:08:50.071] --> initialize(0)\n"
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "I[18:08:50.071] --> reply:initialize(0)\n"
2024-07-28T18:08:50.071 helix_lsp::transport [ERROR] mojo-lsp err <- "D[18:08:50.071] >>> {\"id\":0,\"jsonrpc\":\"2.0\",\"result\":{\"capabilities\":{\"codeActionProvider\":{\"codeActionKinds\":[\"quickfix\",\"refactor\",\"info\"]},\"completionProvider\":{\"allCommitCharacters\":[\"\\t\"],\"resolveProvider\":false,\"triggerCharacters\":[\".\"]},\"definitionProvider\":true,\"documentSymbolProvider\":false,\"foldingRangeProvider\":true,\"hoverProvider\":true,\"inlayHintProvider\":true,\"notebookDocumentSync\":{\"notebookSelector\":[{\"cells\":[{\"language\":\"mojo\"}],\"notebook\":{\"notebookType\":\"jupyter-notebook\",\"scheme\":\"file\"}}]},\"referencesProvider\":true,\"renameProvider\":true,\"semanticTokensProvider\":{\"full\":{\"delta\":true},\"legend\":{\"tokenModifiers\":[],\"tokenTypes\":[\"variable\",\"specialVariable\",\"parameter\",\"function\",\"method\",\"property\",\"class\",\"interface\",\"type\",\"namespace\"]},\"range\":false},\"signatureHelpProvider\":{\"triggerCharacters\":[\"(\",\"[\",\",\"]},\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":true}},\"serverInfo\":{\"name\":\"mojo-lsp-server\",\"version\":\"0.0.1\"}}}\n"
58 replies
MModular
Created by lukas on 5/11/2024 in #community-showcase
tree-sitter-mojo
Hi. These setup instructions are for an older version of tree-sitter. The latest version of helix has out of the box Mojo support https://github.com/helix-editor/helix/blob/master/CHANGELOG.md?plain=1#L134 Can you try it?
58 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
https://github.com/ziglang/zig/issues/8224#issuecomment-847669956
How async should it be? Zig's async is awesome of course. However, here's something surprising from our experience. We tried out Zig's async plus io_uring for TigerBeetle (https://github.com/coilhq/tigerbeetle/blob/main/src/io_async.zig) and then actually went back to explicit callbacks plus io_uring in the end (https://github.com/coilhq/tigerbeetle/blob/main/src/io.zig). The reason being that we were doing this for a distributed consensus protocol where we wanted to make sure our message handlers run to completion with the same system state, whereas coroutines increase dimensionality while a function is still running. We wanted clear jumping off points to I/O just because getting the consensus protocol right was hard enough. This is specific to our use-case for TigerBeetle only, it might not be relevant here, but wanted to share the anecdote if it helps.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
This is mainly due to how their consensus works.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
But that doesn't mean you can't create an extended version with async.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
Tigerbeetle's API is pretty good, but it doesn't use async and all the io_uring features.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
It's my IMHO of course. I think it's good to have efficient building blocks. With async it's different because it's hard to create a runtime that will satisfy all needs.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
Overall, I don't see the value in this abstraction. It has overhead, which means it's not suitable for something like a thread-per core event loop. At the same time, it's not a fully asynchronous runtime.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
It will have some runtime overhead
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
It's not matter. There is no need to duplicate all the code for parameters that will not be used at runtime.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
And we could just use pseudo async API for something that is sync and I see no problem really.
I think the user creating the event loop shouldn't have to pay for asynchrony because they simply don't need it.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
The main goal at the API level is to be generic and each implementation to be able to implement what it says it implements, the constraining is something that as Mojo evolves I think will get better tools
It is not Mojo specific. Just read about generic code bloat. In this particular case it doesn't add any value, it just increases compilation time and binary size.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
It duplicates into independent owned object. So there is no problem with close in it's destructor.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
You do not need Arc to duplicate socket, it's an unnecessary runtime overhead. https://doc.rust-lang.org/src/std/net/tcp.rs.html#237
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
Wrapper can be generic over file descriptor trait with the regular owned file descriptor as the default parameter. This way the user doesn't need to know about io_uring if he doesn't want to.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
Synchronous variant can still be used with io_uring based event loop. For this I had to reimplement Rust's TcpStream since it is useless with a registered socket file descriptor. In this case Mojo can try to be better. For async it is more complicated, and in many cases the runtime has its own implementations of these wrappers.
145 replies
MModular
Created by Dmitry Salin on 7/14/2024 in #community-showcase
io_uring
I don't mind, such an interface is certainly necessary and useful. But there are many things to consider. struct Socket[ sock_family: SockFamily = SockFamily.AF_INET, sock_type: SockType = SockType.SOCK_STREAM, sock_protocol: SockProtocol = SockProtocol.TCP, sock_platform: SockPlatform = _get_current_platform(), ]: ... This struct has over 750 parameter combinations, and even taking into account that not all of them are valid, it's a generic bloat. Restricting and checking combinations at compile time is difficult, and the kernel will do it at runtime anyway. Arc is an extra runtime overhead in this case, if someone needs it, they can easily make such a wrapper. In my opinion, it's better to look at modern systems languages ​​such as Rust and Zig. https://doc.rust-lang.org/src/std/net/tcp.rs.html#50 https://github.com/ziglang/zig/blob/master/lib/std/net.zig#L1788 What they have in common is that both use a zero-cost wrapper for the socket file descriptor. And both are unaware of io_uring registered file descriptors.
145 replies