Release of the programming language Rust 1.75 and unikernel Hermit 0.6.7

The general-purpose programming language Rust 1.75, founded by the Mozilla project but now developed under the auspices of the independent non-profit organization Rust Foundation, has been released. The language focuses on memory safety and provides the means to achieve high job parallelism while avoiding the use of a garbage collector and runtime (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's memory handling methods save the developer from errors when manipulating pointers and protect against problems that arise due to low-level memory handling, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, provide builds and manage dependencies, the project develops the Cargo package manager. The crates.io repository is supported for hosting libraries.

Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership, keeping track of object lifetimes (scopes), and assessing the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

Main innovations:

  • Added the ability to use “async fn” and the “->impl Trait” notation in private traits. For example, using “->impl Trait” you can write a trait method that returns an iterator: trait Container { fn items(&self) -> impl Iterator; } impl Container for MyContainer { fn items(&self) -> impl Iterator { self.items.iter().cloned() } }

    You can also create traits using "async fn": trait HttpService { async fn fetch(&self, url: Url) -> HtmlBody; // will be expanded to: // fn fetch(&self, url: Url) -> impl Future; }

  • Added API for calculating byte offsets relative to pointers. When working with bare pointers (“*const T” and “*mut T”), operations may be required to add an offset to the pointer. Previously, for this it was possible to use a construction like “::add(1)”, adding the number of bytes corresponding to the size of “size_of::()”. The new API simplifies this operation and makes it possible to manipulate byte offsets without first casting the types to "*const u8" or "*mut u8".
    • pointer::byte_add
    • pointer::byte_offset
    • pointer::byte_offset_from
    • pointer::byte_sub
    • pointer::wrapping_byte_add
    • pointer::wrapping_byte_offset
    • pointer::wrapping_byte_sub
  • Continued work to increase the performance of the rustc compiler. Added the BOLT optimizer, which runs in the post-link stage and uses information from a pre-prepared execution profile. Using BOLT allows you to speed up compiler execution by about 2% by changing the layout of the librustc_driver.so library code for more efficient use of the processor cache.

    Included building the rustc compiler with the "-Ccodegen-units=1" option to improve the quality of optimization in LLVM. The tests performed show an increase in performance in the case of the “-Ccodegen-units=1” build by approximately 1.5%. The added optimizations are enabled by default only for the x86_64-unknown-linux-gnu platform.

    The previously mentioned optimizations were tested by Google to reduce the build time of Android platform components written in Rust. Using “-C codegen-units=1” when building Android allowed us to reduce the size of the toolkit by 5.5% and increase its performance by 1.8%, while the build time of the toolkit itself almost doubled.

    Enabling link-time garbage collection (“--gc-sections”) brought the performance gain up to 1.9%, enabling link-time optimization (LTO) up to 7.7%, and profile-based optimizations (PGO) up to 19.8% . In the final, optimizations were applied using the BOLT utility, which made it possible to increase the build speed to 24.7%, but the size of the toolkit increased by 10.9%.

    Release of the programming language Rust 1.75 and unikernel Hermit 0.6.7

  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • Atomic*::from_ptr
    • FileTimes
    • FileTimesExt
    • File::set_modified
    • File::set_times
    • IpAddr::to_canonical
    • Ipv6Addr::to_canonical
    • Option::as_slice
    • Option::as_mut_slice
    • pointer::byte_add
    • pointer::byte_offset
    • pointer::byte_offset_from
    • pointer::byte_sub
    • pointer::wrapping_byte_add
    • pointer::wrapping_byte_offset
    • pointer::wrapping_byte_sub
  • The "const" attribute, which determines the possibility of using it in any context instead of constants, is used in functions:
    • Ipv6Addr::to_ipv4_mapped
    • MaybeUninit::assume_init_read
    • MaybeUninit::zeroed
    • mem::discriminant
    • mem::zeroed
  • The third level of support has been implemented for the csky-unknown-linux-gnuabiv2hf, i586-unknown-netbsd and mipsel-unknown-netbsd platforms. The third level involves basic support, but without automated testing, publishing official builds, or checking whether the code can be built.

Additionally, we can note a new version of the Hermit project, which develops a specialized kernel (unikernel), written in the Rust language, providing tools for building self-contained applications that can run on top of a hypervisor or bare hardware without additional layers and without an operating system. When built, the application is statically linked to a library, which independently implements all the necessary functionality, without being tied to the OS kernel and system libraries. The project code is distributed under Apache 2.0 and MIT licenses. Assembly is supported for stand-alone execution of applications written in Rust, Go, Fortran, C and C++. The project is also developing its own bootloader that allows you to launch Hermit using QEMU and KVM.

Source: opennet.ru

Add a comment