Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core:os tracking issue #4710

Open
7 of 61 tasks
laytan opened this issue Jan 17, 2025 · 9 comments
Open
7 of 61 tasks

core:os tracking issue #4710

laytan opened this issue Jan 17, 2025 · 9 comments

Comments

@laytan
Copy link
Collaborator

laytan commented Jan 17, 2025

We are nearing the replacement of core:os, this issue outlines todos and nice to haves.

Todos:

Targets supported in core:os but not yet in core:os/os2:

  • wasi (os/os2: wasi target support #4716)
  • js - just os.write is implemented, maybe it should just be dropped entirely for os2
  • haiku - should be pretty easy to use the posix implementation at first, can go "native" later

Non blocking but can have api consequences:

  • buffered file mode/flag (needs testing to see if it's beneficial)
  • Jeroen: Virtual File System - file possibly backed by not actual files

Packages that use core:os and need to be updated:

  • core:compress/gzip

  • core:crypto

  • core:encoding/csv

  • core:encoding/hxa

  • core:encoding/ini

  • core:encoding/xml

  • core:flags

  • core:fmt (JS impl needs rewrite to not use core:os at all)

  • core:image/bmp

  • core:image/netpbm

  • core:image/png

  • core:image/qoi

  • core:image/tga

  • core:image

  • core:log

  • core:math/big

  • core:mem/virtual

  • core:net

  • core:odin/parser

  • core:path/filepath

  • core:prof/spall

  • core:testing

  • core:text/i18n

  • core:text/regex

  • core:text/table

  • core:time/timezone

  • core:unicode/tools

  • tests/core/encoding/hxa

  • tests/core/flags

  • tests/core/io

  • tests/documentation

  • vendor:fontstash

  • vendor:libc

  • vendor:opengl

  • odin-lang/examples repo needs to be updated

Nice to have, but not blocking the replacement of core:os:

  • more tests
  • docs additions, dir.odin, file.odin, etc. don't have any docs
  • docs unification, doc style differs between files and procs
  • linux process_info should query /proc/pid/exe instead of the way it's done now to get executable paths
  • netbsd, openbsd, freebsd targets implementation for _process_info_by_pid, _process_list, _process_open, _process_handle_still_valid, _process_state_update_times for full process API coverage (decided to make non blocking because it is a new API)
  • current_executable_path(allocator: runtime.Allocator) -> (string, Error) returning the full absolute executable path of the program, useful for loading things relative to this path. You can already do this in a round about way with: current_process_info({.Executable_Path}, context.allocator) but a more direct way with the native APIs for each target would be nice (os/os2: add get_executable_path and get_executable_directory #4733)
  • wrapper api over the process API that handles the details of processes and just allows easy communication, similar to this idea: https://gist.github.com/laytan/68be38614d9274663a48fd3d710fefc2
  • a heap allocator that does not rely on any system libraries, ideally this goes into base: though, so it can be the default allocator in general (Add native lock-free dynamic heap allocator #4749)
  • core:testing to replace os2.stdout and os2.stderr with an implementation that synchronises between tests (currently writing to stdout or stderr in tests doesn't work well because the terminal renders progress and clears it out)
  • Flysand: There is no procedure to free a file handle without closing it (which can be used in tandem with new_file, if i.e. a library returned a handle, and that library is responsible for closing the file).
  • Flysand: It would be nice to have unlink :: remove alias.

After replacement the following can be closed:

@laytan laytan pinned this issue Jan 17, 2025
@Kelimion
Copy link
Member

Kelimion commented Jan 17, 2025

Virtual File System, working similarly to allocators, in that you call it with a Mode, instead of having to have vtable with all of stat , open , close , read ,write, etc.

@flysand7
Copy link
Contributor

doc style differs between files and procs

Pretty sure I messed up files a little bit. I (or someone else) will have to rewrite the documentation at some point for files. process.odin should be the most recent and the most correct style, but still not ideal.

@laytan
Copy link
Collaborator Author

laytan commented Jan 17, 2025

Virtual File System, working similarly to allocators, in that you call it with a Mode, instead of having to have vtable with all of stat , open , close , read ,write, etc.

I put it on the list under "non blocking but can have api consequences"

@Feoramund
Copy link
Contributor

Feoramund commented Jan 21, 2025

I have a private branch that has a chunk of what's outlined here already done (for os->os2 conversion), including a test suite.

It's been a while since I touched it (~2 months), so I'll have to revisit what's changed since. The main blocker for me was rewriting @jasonKercher's heap allocator to be thread-safe, which took quite some time, debugging, research, and learning of new skills.

I'm aiming to get a draft PR of the new allocator up in a couple days. I'll need some help with testing and reviewing non-Linux system calls with regards to virtual memory, in particular.

I'm currently working through integrating it into base and fixing some cyclic import issues. I had hoped to avoid exposing too many new symbols in base:runtime by using a sub-package such as base:runtime/heap, but fixing the cyclic import would've been too much of a pain, so I'm just putting everything in base now. I'll be using a liberal application of prefixes so it's clear what's only for the heap API. @(private="file") wouldn't work either, because my allocator test bench uses the internals, and I think it's just as well for a low-level API to be available.

EDIT: To be perfectly clear, when I say draft PR, I mean that the allocator is largely finished from a design and implementation standpoint, but it's untested outside of microbenchmarks, my test bench, and the Odin core: test suite. If someone's willing to hook it up to a real application once the PR's up, that'd be great.

@laytan
Copy link
Collaborator Author

laytan commented Jan 21, 2025

Sounds great @Feoramund , excited to see it!

@jasonKercher
Copy link
Contributor

Me too, and I'm very sorry ;]

@flysand7
Copy link
Contributor

flysand7 commented Jan 22, 2025

Some things I've noted when looking at os2/file API:

  1. create() does not allow to set the permission bits or specify the behavior when the file exists (.Trunc or .Excl). I would like to see truncate parameter to that procedure that is false by default. If it's not specified, .Excl is the behavior on existing files, otherwise existing file is truncated.
  2. open_buffered() is still commented out and .Unbuffered_IO flag is unused.
  3. There is no procedure to free a file handle without closing it (which can be used in tandem with new_file, if i.e. a library returned a handle, and that library is responsible for closing the file).
  4. It would be nice to have unlink :: remove alias.

@laytan
Copy link
Collaborator Author

laytan commented Jan 22, 2025

Some things I've noted when looking at os2/file API:

  1. create() does not allow to set the permission bits or specify the behavior when the file exists (.Trunc or .Excl). I would like to see truncate parameter to that procedure that is false by default. If it's not specified, .Excl is the behavior on existing files, otherwise existing file is truncated.
  2. open_buffered() is still commented out and .Unbuffered_IO flag is unused.
  3. There is no procedure to free a file handle without closing it (which can be used in tandem with new_file, if i.e. a library returned a handle, and that library is responsible for closing the file).
  4. It would be nice to have unlink :: remove alias.

I added 1, 3 and 4 to the list, 2 was already there

@Feoramund
Copy link
Contributor

The heap allocator PR is up at #4749

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

No branches or pull requests

5 participants