Блог*
Собственно, баг выражается в том, что при поиске по странице искомые слова в текстовом поле с кодом подсвечиваются дважды. Например: https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/fs.rs Если искать вхождение openat, то браузер показывает…
Причём если открыть эту страницу, не войдя в аккаунт, то подобной херни нету!
Блог*
Собственно, баг выражается в том, что при поиске по странице искомые слова в текстовом поле с кодом подсвечиваются дважды. Например: https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/fs.rs Если искать вхождение openat, то браузер показывает…
Не я один на это напоролся:
https://github.com/orgs/community/discussions/54546#discussioncomment-5856994
Можете сюда стрелок наставить, вдруг поможет.
https://github.com/orgs/community/discussions/54546#discussioncomment-5856994
Можете сюда стрелок наставить, вдруг поможет.
GitHub
🚢 New code search and code view feedback · community · Discussion #54546
This Discussion has been closed because it's outdated. To provide feedback on code search and code view, please click here. At GitHub Universe last year, we announced a total redesign of GitHub...
👍5
Блог*
#prog #rust #rustlib Кому-то в расточате требовались параметризованные тесты. Так вот, такая библиотека есть. crates.io/crates/test-case
#prog #rust #rustlib
rstest — uses procedural macros to help you on writing fixtures and table-based tests.
Поддерживает:
* параметризованные тесты
- с возможностью шарить тест-кейсы между функциями
- с возможностью задавать значение строками для типов, реализующих
* асинхронные тесты
- нативная интеграция только с async-std, но можно использовать тест-атрибуты из других библиотек
* таймауты на тесты целиком
- включая асинхронные
* фикстуры, которые вычисляются только один раз и потом используются для всех тестов с передачей по ссылке
Также значения для аргумента можно задавать списком в самом определении функции. В этом случае будут сгенерированы тесты для декартового произведения всех списков значений аргументов. В README есть наглядный пример, который тут, к сожалению, смотрелся бы крайне неудобно.
rstest — uses procedural macros to help you on writing fixtures and table-based tests.
Поддерживает:
* параметризованные тесты
- с возможностью шарить тест-кейсы между функциями
- с возможностью задавать значение строками для типов, реализующих
FromStr
* фикстуры, использующие другие фикстуры* асинхронные тесты
- нативная интеграция только с async-std, но можно использовать тест-атрибуты из других библиотек
* таймауты на тесты целиком
- включая асинхронные
* фикстуры, которые вычисляются только один раз и потом используются для всех тестов с передачей по ссылке
Также значения для аргумента можно задавать списком в самом определении функции. В этом случае будут сгенерированы тесты для декартового произведения всех списков значений аргументов. В README есть наглядный пример, который тут, к сожалению, смотрелся бы крайне неудобно.
crates.io
crates.io: Rust Package Registry
👍8👎1
#prog #rust #rustlib
mock_instant — библиотека длямгновенного создания моков моканья std::time::Instant, причём независимо для каждого потока. Разумеется, не патчит std, а потому на зависимости не влияет.
mock_instant — библиотека для
crates.io
crates.io: Rust Package Registry
Блог*
#prog #rust #rustlib assay — более мощный тест-раннер для Rust. В частности, позволяет запускать каждый тест в отдельном процессе
#prog #rust #rustlib
testcontainers
A library for integration testing against docker containers from within Rust.
This crate is the official Rust language fork of Testcontainers.
Tests should be self-contained and isolated. While this is usually easy for unit-tests, integration-tests typically require a more complex environment. The testcontainers ecosystem facilitates self-contained and isolated integration tests. It allows to easily spin up Docker containers from within your tests and removes them afterwards.
testcontainers
A library for integration testing against docker containers from within Rust.
This crate is the official Rust language fork of Testcontainers.
Tests should be self-contained and isolated. While this is usually easy for unit-tests, integration-tests typically require a more complex environment. The testcontainers ecosystem facilitates self-contained and isolated integration tests. It allows to easily spin up Docker containers from within your tests and removes them afterwards.
docs.rs
testcontainers - Rust
A library for integration testing against docker containers from within Rust.
👍7
#prog #rust #rustasync #rustlib #amazingopensource
Вот
Странно, что я раньше про это не рассказывал. Для tokio есть инструментарий, который позволяет собирать информацию об исполнении тасок в программе на Rust на tokio и потом эту информацию отображать. Конкретно tokio-console реализует CLI с TUI, но за счёт формата, определённого отдельно, бекенд для визуализации можно сделать и другой.
Вот
Странно, что я раньше про это не рассказывал. Для tokio есть инструментарий, который позволяет собирать информацию об исполнении тасок в программе на Rust на tokio и потом эту информацию отображать. Конкретно tokio-console реализует CLI с TUI, но за счёт формата, определённого отдельно, бекенд для визуализации можно сделать и другой.
🔥21👎1
#prog #rust #article
Atomicless Concurrency
Let’s say we’re building an allocator. Good allocators need to serve many threads simultaneously, and as such any lock they take is going to be highly contended. One way to work around this, pioneered by TCMalloc, is to have thread-local caches of blocks (hence, the “TC” - thread cached).
Unfortunately threads can be ephemeral, so book-keeping needs to grow dynamically, and large, complex programs (like the Google Search ranking server) can have tens of thousands of threads, so per-thread cost can add up. Also, any time a thread context-switches and resumes, its CPU cache will contain different cache lines – likely the wrong ones. This is because either another thread doing something completely different executed on that CPU, or the switched thread migrated to execute on a different core.
These days, instead of caching per-thread, TCMalloc uses per-CPU data. This means that book-keeping is fixed, and this is incredibly friendly to the CPU’s cache: in the steady-state, each piece of the data will only ever be read or written to by a single CPU. It also has the amazing property that there are no atomic operations involved in the fast path, because operations on per-CPU data, by definition, do not need to be synchronized with other cores.
This post gives an overview of how to build a CPU-local data structure on modern Linux. The exposition will be for x86, but other than the small bits of assembly you need to write, the technique is architecture-independent.
Atomicless Concurrency
Let’s say we’re building an allocator. Good allocators need to serve many threads simultaneously, and as such any lock they take is going to be highly contended. One way to work around this, pioneered by TCMalloc, is to have thread-local caches of blocks (hence, the “TC” - thread cached).
Unfortunately threads can be ephemeral, so book-keeping needs to grow dynamically, and large, complex programs (like the Google Search ranking server) can have tens of thousands of threads, so per-thread cost can add up. Also, any time a thread context-switches and resumes, its CPU cache will contain different cache lines – likely the wrong ones. This is because either another thread doing something completely different executed on that CPU, or the switched thread migrated to execute on a different core.
These days, instead of caching per-thread, TCMalloc uses per-CPU data. This means that book-keeping is fixed, and this is incredibly friendly to the CPU’s cache: in the steady-state, each piece of the data will only ever be read or written to by a single CPU. It also has the amazing property that there are no atomic operations involved in the fast path, because operations on per-CPU data, by definition, do not need to be synchronized with other cores.
This post gives an overview of how to build a CPU-local data structure on modern Linux. The exposition will be for x86, but other than the small bits of assembly you need to write, the technique is architecture-independent.
#prog #article
The Alkyne GC
Статья описывает устройство сборщика мусора для скриптового языка программирования. Этот сборщик мусора относительно простой (однопоточный, stop-the-world, mark-and-sweep, без поддержки финализаторов), но не примитивный. На его примере демонстрируются техники оптимизации, которые используются в реальных сборщиках мусора.
The Alkyne GC
Статья описывает устройство сборщика мусора для скриптового языка программирования. Этот сборщик мусора относительно простой (однопоточный, stop-the-world, mark-and-sweep, без поддержки финализаторов), но не примитивный. На его примере демонстрируются техники оптимизации, которые используются в реальных сборщиках мусора.
👍10