« first day (2057 days earlier)      last day (1422 days later) » 

@Stargateur Why the laugh ?
 
@DenysSéguret Well, spawn a thread to drop memory is very funny and "make your code 10000 times faster" is really really funny and false
look like a newbie that "discover" a "wonderful" way to make all code faster, but doesn't understand why he is wrong, and still advice the word of that amazing discovery
 
What might be possible is that dropping is a heavy enough operation to justify doing it after rendering the result or on another thread while you render. The title is clickbait but there's something to consider
 
yeah heavy operation but here the article is clear about memory dropping
that a real misunderstood about how memory is manage in 99% of program.
and a very bad advice to give and spread
 
There aren't many cases where it can make sense, sure
I was wondering for broot, due to the very big tree which is built in memory during the construction of the very small one which is kept. But due to lifetime things it's not easy to measure. It's already in an arena so I suspect there's not much to gain but I would have liked to check
 
4:50 AM
well, avoid allocating when possible :p
specially avoid allocating small thing
 
You know I know that
 
in the article OP allocate 1M object
 
But parallel diving in the tree of all your disk's files and keeping search ranking for all those files can't really be done without allocation. The arena helps, of course.
 
I think there is crate for tree that do one big allocation
 
The arena ensures there aren't too many allocations, but there are still pathbufs and strings which aren't in. I should look more into that
TBH dropping is probably ridiculously small compared to other costs but I'm curious
 
4:56 AM
I think you could test it implementing drop and go some into_raw
or override deallocation and do nothing
 
I'll try to measure the intermediate tree dropping asap... if I survive a day of online meetings...
 
 
7 hours later…
12:18 PM
@DenysSéguret too bad broot is persistent; if it was started and stopped, you could just do mem::drop ;-)
 
pollen try to kill me it clearly visible it target me
 
You mean you're in the small red area ?
 
yeah...
 
I am too, so we must be neighbours
 
yesterday, I forgot not to rub my eyes, suddenly I have no right eye
don't rub your eyes look easy but it's not
 
12:24 PM
I know
Do you clean your eyes with a saline solution ?
 
only good old classic water
 
Saline solution might be cleaner. I know it's very efficient for me when my eyes are attacked by pollen or bacteries
 
that more my immune system that attack the pollen and so attack me for nothing :p
a good thing would be taking some corticosteroid but reduce the strong of my immune system doesn't seem like a good deal
 
yeah. Obviously I'm not a doctor but if you can manage to avoid corticosteroids, it's better long term
 
I will survive ^^, I just have all symptoms of being very sick without actually being really sick... some years it's worse than other but I think the last time where I was this bad it was 5-6 years ago.
 
 
2 hours later…
2:49 PM
Error 👏👏👏
I AM ERROR
 
@E_net4isdownhausted sure copy is cheap on this one
 
@E_net4isdownhausted not even std::error::Error
 
@Stargateur "Our errors are a true zero cost abstraction!"
 
@Shepmaster XD
impl<T> Same<T> for T
wtf
and doc doesn't link to what is Same
 
Nice
Deleted by the OP.
 
2:53 PM
that a really strange naming too
"Collection of traits which describe functionality of cryptographic primitives."
but contain aead Authenticated encryption
so the real program ?
shapez.io look funny
 
Hi all. Question of the week from me: How does one interrupt a File read?
 
4
Q: What is the standard way to get a Rust thread out of blocking operations?

HaraldComing from Java, I am used to idioms along the lines of while (true) { try { someBlockingOperation(); } catch (InterruptedException e) { Thread.currentThread.interrupt(); // re-set the interrupted flag cleanup(); // whatever is necessary break; } } This works, as far as ...

 
XD
 
3:08 PM
tl;dr you don't.
 
sht
 
You can use Tokio's files to make it look like you can
but there will be a thread sitting there blocked
 
I really need to interrput the read though
 
why ?
 
I was under the impression that if i could some close the file handler it would interrupt
 
3:10 PM
and how do you close the file handler while your thread is blocked ?
 
@Stargateur I am working with a system that may have parts of it's data that are unreadable, or given a lot of time, be able to determine the data. I want to interrupt the slow reads, get the quick reads through, and then do a second pass or the slow reads
@Stargateur From outside the thread, maybe via a timeout. unsafe code...
 
@NebulaFox each thread get a copy of its handle of file
but if you need async feature use async crate so tokio & co
don't try to do impossible thing in blocking mode ^^
 
that's the thing I don't need async, I need to interrupt
 
to accomplish your goal, async should be fine
you'd make requests to everything, then race the responses against a timeout future
 
> There is no such thing. Blocking means blocking.
 
3:14 PM
everything that finished by then counts as "fast"
and you can continue polling the "slow" futures later
 
but won't the read be block by the "slow"?
 
With async, you can do non-blocking I/O.
 
but there is a block somewhere
 
"async" file IO works by running each IO operation on a separate thread.
Your primary thread(s) will not block
 
3:19 PM
but there will be an IO block, is what I'm getting at
not the main thread, per say
 
(per se)
 
@Shepmaster wut
 
but yes
 
that not really how tokio work
 
is it not?
 
3:19 PM
@Stargateur indeed it is...
 
@Shepmaster tokio use mio than use epoll for most system
 
tokio also has the block_in_place; is that what you are referring to?
 
@Shepmaster Not if you use a single-threaded runtime...
 
tokio can use the node model?
 
I don't know what it is
 
3:21 PM
@PeterHall hmmmmmmm
 
Each io operation is a separate task perhaps
 
> Tasks run by worker threads should not block, as this could delay servicing reactor events. Portable filesystem operations are blocking, however. This module offers adapters which use a blocking annotation to inform the runtime that a blocking operation is required. When necessary, this allows the runtime to convert the current thread from a worker to a backup thread, where blocking is acceptable.
 
It uses both
pool of threads and single-thread mode
 
I think the single-threaded runtime means that there's only one thread running tasks, not that there's only one thread total
 
@Shepmaster oh I see, this is hidden
 
3:23 PM
Nope, you can run it entirely in "current" thread
 
well epoll is blocking so it's make sense
 
epoll is blocking, but you do EVERYTHING on a new epoll event
If there is no epoll event then there is nothing to do
 
@PeterHall then I simply don't understand how this can work in a single thread
 
@PeterHall but tokio handle a lot of thing not only file
what if a timer expire ?
 
At my company we did a series of group coding sessions, building up examples with pure mio and porting to tokio
and the mio code is one loop (and a nasty state machine)
 
3:25 PM
unless mio use timeout 0 I don't see how
 
yay state machines... all i can add to this conversation
 
I'll dig out some code...
 
@PeterHall I'm also asking in the Tokio Discord. Get some multihomed answers
 
So, as far as I can see, there is no way to interrupt an IO operation (read) to free up the IO
 
@NebulaFox correct.
It's possible that Linux's io_uring would help
but that's super new
 
3:27 PM
oh yeah, that looks awesome
 
> rt-core -> rt-threaded only means the capability of more than 1 core/worker threads; fs uses spawn_blocking which will use multiple threads regardless of the runtime type
BOO
YAH
 
But a few years before you can use that in production still :)
 
BOOYAH
 
I'm going to be stupid here, but why can't I interrupt IO?
 
Not stupid. It's a hard question.
To start with; do you believe it to be possible to do if you only have one thread?
 
@NebulaFox because of the Categorical Imperative - I mean, you wouldn't want IO to keep interrupting you would you?
 
@Shepmaster No it can't be done in one thread. It is always going to have to be done by something or someone else – user, another theard, process, daemon...
 
because on OS side it's hard to have a callback way to inform you data is available.
 
@NebulaFox ok, good.
 
so you are force to block until OS call tell you your data is here
 
3:31 PM
So, we'd have to share something between the threads.
on linux that potentially could be a fd
 
go with unix XD
 
and then there could be a OS function to interrupt any outstanding IO
which would cause the original call to error with E_INTR
(to be clear, I don't actually know the answer here, so this is all thinking aloud)
 
Which I assume E_INTR is ErrorKind::Interrupted in std::io::Error
@Shepmaster This is sort of what I have read elsewhere
 
> Note that if you are using the basic scheduler, this function will still spawn additional threads for blocking operations. The basic scheduler's single thread is only used for asynchronous code.
 
3:42 PM
So for a unix system, I need to send a EINTR somehow
 
So maybe then I should use processes instead of threads and then send a SIGINT
 
@NebulaFox and that will go to everything in the process
 
@Shepmaster If the processes only includes the io read then that's fine
 
@NebulaFox how does the data that you read in that process get anywhere else?
 
3:48 PM
@Shepmaster I can create a bunch of tmp files that somehow magically can be combined into a data file
 
@NebulaFox and write to them? write can be interrupted
0
A: How to write a test case to verify EINTR returned by sem_wait function in linux

Jonathon ReinhartJust about any system call on Linux can return EINTR if the system call is interrupted. From the man page (emphasis mine): sem_wait() decrements (locks) the semaphore pointed to by sem. If the semaphore's value is greater than zero, then the decrement proceeds, and the fun...

you might be able to use pthread_kill to send a signal to a thread.
 
@Shepmaster it's only the io read that gets blocked for long periods of time, writing io will be fine
 
@NebulaFox my point is if read takes 900ms and write takes 200ms, but you send the signal at 1000ms...
 
in my experience, signal is shit
 
@Shepmaster then that particalur bit of data will get zeroed out, not written as such, but will be null, until a second pass comes around allowing for a longer time
 
3:54 PM
@NebulaFox the second pass still sounds wrong to me, which is why I'd advocate for the async thing from the start
start all the reads, return the fast results, then wait for the slow ones
that way you don't _re_start the slow reads
 
@Shepmaster THe slow will block ALL reads
 
why?
 
@Shepmaster That makes sense. If you want your app to be single-threaded then you don't need a fancy runtime-provided function to block the thread :)
 
@Shepmaster because the system can only read one thing at atime
 
@NebulaFox what system? This statement is not true in general.
@PeterHall I'm missing something. I'm pretty sure I proved you wrong... ?
 
3:58 PM
@Shepmaster THe system that I'm reading from. Good old CD. Single head. Single read.
Doesn't hard drive suffer from the same problem?
 
@NebulaFox depends on a lot of things...
for example, AIUI, most devices have a queue of requests to service
and try to make it efficient w.r.t. where the read head is
(not relevant for SSD, of course)
 
@Shepmaster If it's FIFO, I'd rather it just skip the bad data and give me much of the good data as it can. It can later spend time on the bad data and try error correcting.
Which is why I'm thinking of it in passes
 
4:17 PM
@Shepmaster You're not wrong, but I think we are talking slightly at cross-purposes. You can have a single-threaded tokio app and use IO without spawning new threads. But your blocking operations will necessarily block the main thread. You can't avoid that without spawning another thread - which is what spawn_blocking will do.
And you can still do non-blocking IO in that single thread.
From what I can tell, that is why we appeared to disagree: I'm saying that you can do non-blocking IO in a single thread (it should be obvious that you can also do blocking IO in a single thread), and I think you are just saying that you need a second thread to avoid a blocking operation from blocking the main thread.
 
4:33 PM
@NebulaFox I don't believe it's always FIFO — that's what I mean about the read head.
It could pick the next from the queue that is most efficient to seek to
not that was submitted first
Either way, I think that your case can go all the way down the abstraction stack.
It might depend on exactly the device model of the drive itself.
 
 
3 hours later…
7:24 PM
Once more I support linus :p
by the way he used the same argument I used about rustc requirement breaking change
"People with restrictive hardware shouldn't make it more inconvenient
for people who have better resources."
> And yes, we do use wide tabs, because that makes indentation something
you can visually see in the structure at a glance and on a
whole-function basis, rather than something you have to try to
visually "line up" things for or count spaces.
nobody is perfect ^^
 
 
1 hour later…
I like tree
 

« first day (2057 days earlier)      last day (1422 days later) »