Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance regression on big gherkin::Features (#331) #352

Merged
merged 18 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@ All user visible changes to `cucumber` crate will be documented in this file. Th

### BC Breaks

- Bumped up [MSRV] to 1.83 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [f1307038], [todo])
- Bumped up [MSRV] to 1.83 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [f1307038], [b46930c3])
- Replaced `Arc` with `PartialEq`/`Hash` pointer-optimized `Source` in `event`s: ([#352])
- `Source<gherkin::Feature>` in `event::Cucumber::Feature`.
- `Source<gherkin::Rule>` in `event::Feature::Rule`.
- `Source<gherkin::Scenario>` in `event::Feature::Scenario` and `event::Rule::Scenario`.
- `Source<gherkin::Step>` in `event::Scenario::Background` and `event::Scenario::Step`.
- Made non-`const` the following constructor functions for input type polymorphism: ([#352])
- `event::Cucumber::feature_started()` and `event::Cucumber::feature_finished()`.
- `event::Cucumber::rule_started()` and `event::Cucumber::rule_finished()`.
- `event::Scenario::step_started()`, `event::Scenario::step_passed()` and `event::Scenario::step_skipped()`.
- `event::Scenario::background_step_started()`, `event::Scenario::background_step_passed()` and `event::Scenario::background_step_skipped()`.

### Fixed

- Performance degradation on large `.feature` files. ([#352], [#331])

[#331]: /../../issues/331
[#352]: /../../pull/352
[4010c1ad]: /../../commit/4010c1ad6a53d6b7f0b28cefea73c8c13e880e9f
[b46930c3]: /../../commit/b46930c32ef5ae490df8063905144a45de27eda1
[f1307038]: /../../commit/f1307038cb6b1e38c1cc259a0e09fb583033d0cf
[todo]: /../../commit/todo



Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ humantime = "2.1"
itertools = "0.14"
linked-hash-map = "0.5.3"
pin-project = "1.0"
ref-cast = "1.0.16"
regex = "1.9"
sealed = "0.6"
smart-default = "0.7.1"
Expand Down
6 changes: 3 additions & 3 deletions book/src/architecture/runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ impl CustomRunner {

panic::set_hook(hook);

let scenario = Arc::new(scenario);
let scenario = event::Source::new(scenario);
stream::once(future::ready(event::Scenario::Started))
.chain(stream::iter(steps.into_iter().flat_map(|(step, ev)| {
let step = Arc::new(step);
let step = event::Source::new(step);
[
event::Scenario::Step(step.clone(), event::Step::Started),
event::Scenario::Step(step, ev),
Expand All @@ -213,7 +213,7 @@ impl CustomRunner {
fn execute_feature(
feature: gherkin::Feature,
) -> impl Stream<Item = event::Cucumber<AnimalWorld>> {
let feature = Arc::new(feature);
let feature = event::Source::new(feature);
stream::once(future::ready(event::Feature::Started))
.chain(
stream::iter(feature.scenarios.clone())
Expand Down
6 changes: 3 additions & 3 deletions book/src/architecture/writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ Finally, let's implement a custom [`Writer`] which simply outputs [cucumber even
#
# panic::set_hook(hook);
#
# let scenario = Arc::new(scenario);
# let scenario = event::Source::new(scenario);
# stream::once(future::ready(event::Scenario::Started))
# .chain(stream::iter(steps.into_iter().flat_map(|(step, ev)| {
# let step = Arc::new(step);
# let step = event::Source::new(step);
# [
# event::Scenario::Step(step.clone(), event::Step::Started),
# event::Scenario::Step(step, ev),
Expand All @@ -203,7 +203,7 @@ Finally, let's implement a custom [`Writer`] which simply outputs [cucumber even
# fn execute_feature(
# feature: gherkin::Feature,
# ) -> impl Stream<Item = event::Cucumber<AnimalWorld>> {
# let feature = Arc::new(feature);
# let feature = event::Source::new(feature);
# stream::once(future::ready(event::Feature::Started))
# .chain(
# stream::iter(feature.scenarios.clone())
Expand Down
4 changes: 2 additions & 2 deletions codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ All user visible changes to `cucumber-codegen` crate will be documented in this

### BC Breaks

- Bumped up [MSRV] to 1.83 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [f1307038], [todo])
- Bumped up [MSRV] to 1.83 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [f1307038], [b46930c3])

[4010c1ad]: /../../commit/4010c1ad6a53d6b7f0b28cefea73c8c13e880e9f
[b46930c3]: /../../commit/b46930c32ef5ae490df8063905144a45de27eda1
[f1307038]: /../../commit/f1307038cb6b1e38c1cc259a0e09fb583033d0cf
[todo]: /../../commit/todo



Expand Down
10 changes: 10 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ mod attribute;
mod parameter;
mod world;

// TODO: Remove once tests run without complains about it.
#[cfg(test)]
mod actually_used_crates_in_doc_tests {
use cucumber as _;
use derive_more as _;
use futures as _;
use tempfile as _;
use tokio as _;
}

use proc_macro::TokenStream;

/// Helper macro for generating public shims for [`macro@given`], [`macro@when`]
Expand Down
Loading
Loading