Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A painfully simple logger that makes use of Rust language features to ensure that it's allocated only when it is used, is RAII safe, and is mostly memory safe.

A lot of boilerplate C or C++ code was eliminated, and while we never see the actual assembly, we're told that it would generate similar instruction sets to the C C++ implementations.

So we should get pretty good performance out of it!?



I mean, it'll produce similar assembly to C++ code that does the same, but grabbing a mutex for every log message is not going to give you amazing performance. That's okay in this example, because the log seems to be compiled out by default and only used for debugging Servo, but if you're gunning for performance I'd suggest using thread-local storage to store logs per thread without any atomics and aggregating on a timer.


true and it does suffer from deadlocking (which the author states is a possibility, if one thread never releases the mutex)! Either way, it is a very lightweight implementation and Rust does shine here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: