Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/cruel-candles-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Added proper parsing and formatting for Svelte directives when the `html.experimentalFullSupportEnabled` is set to `true`.
11 changes: 0 additions & 11 deletions .claude/settings.local.json

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/benchmark_html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Benchmarks HTML
on:
workflow_dispatch:
merge_group:
pull_request:
types: [ opened, synchronize ]
branches:
- main
- next
paths:
- 'Cargo.lock'
- 'crates/biome_html_analyze/**/*.rs'
- 'crates/biome_html_formatter/**/*.rs'
- 'crates/biome_html_parser/**/*.rs'
- 'crates/biome_html_*/**/*.rs'
- 'crates/biome_formatter/**/*.rs'
- 'crates/biome_rowan/**/*.rs'
- 'crates/biome_parser/**/*.rs'
push:
branches:
- main
- next
paths:
- 'Cargo.lock'
- 'crates/biome_html_analyze/**/*.rs'
- 'crates/biome_html_formatter/**/*.rs'
- 'crates/biome_html_parser/**/*.rs'
- 'crates/biome_html_*/**/*.rs'
- 'crates/biome_formatter/**/*.rs'
- 'crates/biome_rowan/**/*.rs'
- 'crates/biome_parser/**/*.rs'

env:
RUST_LOG: info

jobs:
bench:
permissions:
contents: read
pull-requests: write
name: Bench
runs-on: depot-ubuntu-24.04-arm-16
strategy:
matrix:
package:
- biome_html_parser
- biome_html_formatter
- biome_html_analyze

steps:

- name: Checkout PR Branch
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
channel: stable
cache-target: release
bins: cargo-codspeed
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Compile
timeout-minutes: 20
run: cargo codspeed build -p ${{ matrix.package }}
env:
CARGO_BUILD_JOBS: 3 # Default is 4 (equals to the vCPU count of the runner), which leads OOM on cargo build

- name: Run the benchmarks
uses: CodSpeedHQ/action@972e3437949c89e1357ebd1a2dbc852fcbc57245 # v4.5.1
timeout-minutes: 50
with:
mode: simulation
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Profile-*.json
**/build
.pnpm-debug.log
.vercel
.claude/settings.local.json

# https://github.com/nnethercote/dhat-rs output file
dhat-heap.json
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ anyhow = "1.0.100"
biome_analyze = { path = "./crates/biome_analyze", version = "0.5.7" }
biome_aria = { path = "./crates/biome_aria", version = "0.5.7" }
biome_aria_metadata = { path = "./crates/biome_aria_metadata", version = "0.5.7" }
biome_bench_utils = { path = "./crates/biome_bench_utils" }
# not publish
biome_cli = { path = "./crates/biome_cli" }
biome_configuration = { path = "./crates/biome_configuration" }
Expand Down
11 changes: 11 additions & 0 deletions crates/biome_html_analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ license.workspace = true
keywords.workspace = true
categories.workspace = true

[[bench]]
harness = false
name = "html_analyzer"

[dependencies]
biome_analyze = { workspace = true }
biome_aria_metadata = { workspace = true }
Expand All @@ -30,9 +34,16 @@ serde = { workspace = true, features = ["derive"] }
biome_html_parser = { path = "../biome_html_parser" }
biome_test_utils = { path = "../biome_test_utils" }
camino = { workspace = true }
criterion = { package = "codspeed-criterion-compat", version = "=3.0.5" }
insta = { workspace = true, features = ["glob"] }
tests_macros = { path = "../tests_macros" }

[target.'cfg(all(target_family="unix", not(all(target_arch = "aarch64", target_env = "musl"))))'.dev-dependencies]
tikv-jemallocator = { workspace = true }

[target.'cfg(target_os = "windows")'.dev-dependencies]
mimalloc = { workspace = true }

[features]
schema = ["schemars"]

Expand Down
86 changes: 86 additions & 0 deletions crates/biome_html_analyze/benches/html_analyzer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
use biome_analyze::options::JsxRuntime;
use biome_analyze::{
AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never,
RuleCategoriesBuilder,
};
use biome_html_parser::{HtmlParseOptions, parse_html};
use biome_html_syntax::HtmlFileSource;
use biome_test_utils::BenchCase;
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
use std::collections::HashMap;

#[cfg(target_os = "windows")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(all(
any(target_os = "macos", target_os = "linux"),
not(target_env = "musl"),
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

// Jemallocator does not work on aarch64 with musl, so we'll use the system allocator instead
#[cfg(all(target_env = "musl", target_os = "linux", target_arch = "aarch64"))]
#[global_allocator]
static GLOBAL: std::alloc::System = std::alloc::System;
fn bench_analyzer(criterion: &mut Criterion) {
let mut all_suites = HashMap::new();
all_suites.insert("html", include_str!("libs-html.txt"));
let mut libs = vec![];
libs.extend(all_suites.values().flat_map(|suite| suite.lines()));

let mut group = criterion.benchmark_group("html_analyzer");

for lib in libs {
let test_case = BenchCase::try_from(lib);

match test_case {
Ok(test_case) => {
let code = test_case.code();
let file_source = HtmlFileSource::html();
group.throughput(criterion::Throughput::Bytes(code.len() as u64));
group.bench_with_input(
BenchmarkId::from_parameter(test_case.filename()),
code,
|b, _| {
let parse = parse_html(code, HtmlParseOptions::from(&file_source));

let filter = AnalysisFilter {
categories: RuleCategoriesBuilder::default()
.with_syntax()
.with_lint()
.with_assist()
.build(),
..AnalysisFilter::default()
};
let options = AnalyzerOptions::default().with_configuration(
AnalyzerConfiguration::default()
.with_jsx_runtime(JsxRuntime::default()),
);

b.iter(|| {
biome_html_analyze::analyze(
&parse.tree(),
filter,
&options,
file_source,
|event| {
black_box(event.diagnostic());
black_box(event.actions());
ControlFlow::<Never>::Continue(())
},
);
});
},
);
}
Err(e) => println!("{e:?}"),
}
}

group.finish();
}

criterion_group!(html_analyzer, bench_analyzer);
criterion_main!(html_analyzer);
1 change: 1 addition & 0 deletions crates/biome_html_analyze/benches/libs-html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://raw.githubusercontent.com/dyc3/opentogethertube/e6b44c716289a8babb2f70624e452542e45c2a1b/client/index.html
Loading
Loading