I simply try to make a console write without loosing runtime to unwrap the result of bytes written on the console... which doesn't interest me for fast tty escape sequence graphic,
I have few options:
-find a way to use:
but without the .unwrap() which is a runtime penalty...
-write my own asm syscall , or maybe libc syscall ...
any idea ?
Well its sim that rust impose to check the validity of the syscall I can understand that as safe language but for fast console video game that can't not always be a good choice... is really that the lack of flexibility in Rust ?
It is possible, but what for? Usage of extra ~ 16/24 bytes in stack is neglectable,
in compare to switching kernel/user space + execution of "tty" driver code in linux kernel + code to rendering output in your preferable terminal.
I am not sure that you can measure this achievement (removing of usage of 24 bytes on stack).
Time of copy several bytes + substract/add to stack pointer is not 1% of write system call,
I am not even sure that it is 0.000_0001% of write system call.
you mean than from os point of view the only way to do better is to make a custom sys call from os... and call it from rust ? so from rust there are no possible optimisation on how the officials sys call write can be efficiently called ?
by the way does locking the stdout() improve speed on it ?
On Rust you can use libc::write or directly call write syscall via syscall macro.
But what I mean this optimization have no sense, because of when you do benchmark you can not see the difference, and if there is no difference what is the point for optimization?
If you want to get real speedup for your program, then this is depend on your program. If you provide flamegraph from perf it would be possible for other advise something.
For example if you read data from socket/file and then print to stdout you can speedup it via sendfile.
Yes, because of otherwise you have to lock each time you call write.
But again you can or can not see any difference in real program, because of
that depend on your program.