I made project-wide search in my text editor asynchronous so results stream in from worker threads without blocking the main thread. However, searching is so fast that it finishes before the next frame renders, even on the largest project I work on, so it was entirely wasted effort.
@jsbarretto it's not really a waste when the async I/O is likely the reason the frame was rendered on time
@natty The I/O isn't itself meaningly faster (workers still block on file access, so it's only asynchronous from the perspective of the main threads). But I was hoping to see the number of results tick up in a more satisfying way instead of appearing instantly. I realise that this is a silly thing to be sad about though
@jsbarretto @natty do a tokio
@dysfun @natty Ah yes, the "I hope spawning a thread is cheaper than reading this tiny text file from the fs cache" gamble

@jsbarretto @natty a bit relevant to me this week as i build a new foundation for async i/o.

in C.

@jsbarretto @natty (nightmare of course is not even cross platform, it's the bit where i don't have any cool facilities and have to using blocking i/o and a threadpool)
@dysfun @natty Hmm, is a thread pool useful in that context? If you're heavily I/O-bound then you'll just want to spin up more soft threads than hardware threads to have many operations in-flight. If not I/O-bound, then context switch overhead might be quite high
@jsbarretto @natty huh? i mean when there are no async file i/o apis. so the most obvious thing you could call 'in flight' is literally one op per OS thread.
@dysfun @natty Yes: but you'll want to be spinning up lots of threads instead of just using a fixed pool (unless I'm misunderstanding the operation of your pool and it just grows when under pressure).

@jsbarretto @natty oh, i haven't decided what to do yet. like your example, is it worth spinning up a new thread for what could be a small op?

OTOH, if we don't do that, we have to have elaborate thread management

open_options.rs - source

Source of the Rust file `src/fs/open_options.rs`.

@jsbarretto @natty i know. but actually i think it's funnier that tokio starts tens of threads of my machine even if i do no i/o than that it does this.

also the docs said something about a 1000 thread default limit so shrug

@dysfun @natty I assume that's just to avoid exhausting memory / thread ID limits or something in the case of very slow I/O?
@jsbarretto @natty i've no idea. i am allergic to tokio and its build times so i try not to keep up with them.

@dysfun

Its build times? But Cargo caches the build result.

@jsbarretto @natty