From efb6272e6e5102610654904ce4de7fddf6a6864d Mon Sep 17 00:00:00 2001 From: ksew1 Date: Fri, 21 Feb 2025 18:50:07 +0100 Subject: [PATCH 1/3] Update Rust edition to 2024 commit-id:c0d0c885 --- Cargo.toml | 2 +- crates/cairo-profiler/src/profile_builder.rs | 17 +++++++++++++---- crates/cairo-profiler/src/profile_viewer.rs | 6 ++++-- crates/cairo-profiler/src/sierra_loader.rs | 4 ++-- .../src/trace_reader/function_trace_builder.rs | 2 +- crates/cairo-profiler/tests/e2e.rs | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 46c36b9..069c86c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ [workspace.package] version = "0.8.0" -edition = "2021" +edition = "2024" [workspace.dependencies] diff --git a/crates/cairo-profiler/src/profile_builder.rs b/crates/cairo-profiler/src/profile_builder.rs index 1c5ed75..91a87bb 100644 --- a/crates/cairo-profiler/src/profile_builder.rs +++ b/crates/cairo-profiler/src/profile_builder.rs @@ -9,7 +9,7 @@ mod perftools { use anyhow::{Context, Result}; use bytes::{Buf, BytesMut}; use camino::Utf8PathBuf; -use flate2::{bufread::GzEncoder, Compression}; +use flate2::{Compression, bufread::GzEncoder}; use prost::Message; use std::collections::{HashMap, HashSet}; use std::{fs, io::Read}; @@ -113,7 +113,10 @@ impl ProfilerContext { locations_ids.push(LocationId(location.id)); } else { let mut location = match &function_stack[0] { - FunctionCall::EntrypointCall(function_name) | FunctionCall::InternalFunctionCall(InternalFunctionCall::NonInlined(function_name) | Syscall(function_name)) => { + FunctionCall::EntrypointCall(function_name) + | FunctionCall::InternalFunctionCall( + InternalFunctionCall::NonInlined(function_name) | Syscall(function_name), + ) => { let line = pprof::Line { function_id: self.function_id(function_name).into(), line: 0, @@ -126,7 +129,11 @@ impl ProfilerContext { is_folded: true, } } - FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => unreachable!("First function in a function stack corresponding to a single location cannot be inlined") + FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => { + unreachable!( + "First function in a function stack corresponding to a single location cannot be inlined" + ) + } }; for function in function_stack.get(1..).unwrap_or_default() { @@ -144,7 +151,9 @@ impl ProfilerContext { | FunctionCall::InternalFunctionCall( InternalFunctionCall::NonInlined(_) | Syscall(_), ) => { - unreachable!("Only first function in a function stack corresponding to a single location can be not inlined") + unreachable!( + "Only first function in a function stack corresponding to a single location can be not inlined" + ) } } } diff --git a/crates/cairo-profiler/src/profile_viewer.rs b/crates/cairo-profiler/src/profile_viewer.rs index 36239cc..5a51be5 100644 --- a/crates/cairo-profiler/src/profile_viewer.rs +++ b/crates/cairo-profiler/src/profile_viewer.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result}; use camino::Utf8PathBuf; use flate2::read::GzDecoder; -use prettytable::{format, Table}; +use prettytable::{Table, format}; use prost::Message; use std::collections::HashMap; use std::fs; @@ -133,7 +133,9 @@ pub fn print_profile(profile: &Profile, sample: &str, limit: NonZeroUsize) -> Re .context("Failed to get current percentage from profile data")? ); - println!("\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total"); + println!( + "\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total" + ); println!("Showing top {effective_limit} nodes out of {profile_length}\n"); let mut table = Table::new(); diff --git a/crates/cairo-profiler/src/sierra_loader.rs b/crates/cairo-profiler/src/sierra_loader.rs index 0ea446e..6338a33 100644 --- a/crates/cairo-profiler/src/sierra_loader.rs +++ b/crates/cairo-profiler/src/sierra_loader.rs @@ -1,8 +1,8 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; +use cairo_annotations::annotations::TryFromDebugInfo; use cairo_annotations::annotations::profiler::{ ProfilerAnnotationsV1, VersionedProfilerAnnotations, }; -use cairo_annotations::annotations::TryFromDebugInfo; use cairo_annotations::trace_data::{CallTraceNode, CallTraceV1}; use cairo_lang_sierra::debug_info::DebugInfo; use cairo_lang_sierra::program::{Program, ProgramArtifact, VersionedProgram}; diff --git a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs index 942cf27..26eec72 100644 --- a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs +++ b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs @@ -10,7 +10,7 @@ use crate::trace_reader::sample::{FunctionCall, InternalFunctionCall, Sample}; use crate::versioned_constants_reader::OsResources; use cairo_annotations::annotations::profiler::{FunctionName, ProfilerAnnotationsV1}; use cairo_annotations::trace_data::CasmLevelInfo; -use cairo_annotations::{map_pcs_to_sierra_statement_ids, MappingResult}; +use cairo_annotations::{MappingResult, map_pcs_to_sierra_statement_ids}; use cairo_lang_sierra::extensions::core::{CoreConcreteLibfunc, CoreLibfunc, CoreType}; use cairo_lang_sierra::extensions::starknet::StarkNetConcreteLibfunc; use cairo_lang_sierra::program::{GenStatement, Program, StatementIdx}; diff --git a/crates/cairo-profiler/tests/e2e.rs b/crates/cairo-profiler/tests/e2e.rs index ad0790d..7b395de 100644 --- a/crates/cairo-profiler/tests/e2e.rs +++ b/crates/cairo-profiler/tests/e2e.rs @@ -1,6 +1,6 @@ use assert_fs::fixture::PathCopy; use indoc::indoc; -use snapbox::cmd::{cargo_bin, Command as SnapboxCommand}; +use snapbox::cmd::{Command as SnapboxCommand, cargo_bin}; use std::str; use test_case::test_case; From 6af2bd5d53d885ffe8c5024d734cd06d7973d754 Mon Sep 17 00:00:00 2001 From: ksew1 Date: Fri, 21 Feb 2025 18:58:56 +0100 Subject: [PATCH 2/3] Bump action deps commit-id:44178492 --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/release.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f9c838..17b7205 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab + - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - uses: arduino/setup-protoc@v3 - uses: actions/setup-go@v5 - run: cargo test --release @@ -25,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab + - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - run: cargo fmt --check clippy: @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab + - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - uses: arduino/setup-protoc@v3 - run: cargo lint @@ -47,4 +47,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: typos-action - uses: crate-ci/typos@v1.28.1 + uses: crate-ci/typos@212923e4ff05b7fc2294a204405eec047b807138 # v1.29.9 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b44615..b2d94c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - name: Get version from Cargo.toml id: lookupVersion - uses: mikefarah/yq@bc5b54cb1d1f720db16c9f75c5b45384d00e5cbf + uses: mikefarah/yq@8bf425b4d1344db7cd469a8d10a390876e0c77fd #v4.45.1 with: cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml' @@ -68,12 +68,12 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@315e265cd78dad1e1dcf3a5074f6d6c47029d5aa + - uses: dtolnay/rust-toolchain@stable with: toolchain: stable target: ${{ matrix.target }} - - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab + - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - name: Install cross if: matrix.cross @@ -147,7 +147,7 @@ jobs: - name: Create GitHub release id: create-release - uses: taiki-e/create-gh-release-action@72d65cee1f8033ef0c8b5d79eaf0c45c7c578ce3 + uses: taiki-e/create-gh-release-action@b7abb0cf5e72cb5500307b577f9ca3fd4c5be9d2 # v1.8.4 with: token: ${{ secrets.GITHUB_TOKEN }} changelog: CHANGELOG.md From 407db01790a16c4d01d7d85122a34d24824f62d8 Mon Sep 17 00:00:00 2001 From: ksew1 Date: Fri, 21 Feb 2025 22:33:01 +0100 Subject: [PATCH 3/3] Change `allow` to `expect` commit-id:9aba34ec --- crates/cairo-profiler/src/profile_builder.rs | 4 ++-- crates/cairo-profiler/src/profile_viewer.rs | 2 +- .../cairo-profiler/src/trace_reader/function_trace_builder.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cairo-profiler/src/profile_builder.rs b/crates/cairo-profiler/src/profile_builder.rs index 91a87bb..7d96198 100644 --- a/crates/cairo-profiler/src/profile_builder.rs +++ b/crates/cairo-profiler/src/profile_builder.rs @@ -1,6 +1,6 @@ mod perftools { - #[allow(clippy::doc_link_with_quotes)] - #[allow(clippy::doc_markdown)] + #[expect(clippy::doc_link_with_quotes)] + #[expect(clippy::doc_markdown)] pub mod profiles { include!(concat!(env!("OUT_DIR"), "/perftools.profiles.rs")); } diff --git a/crates/cairo-profiler/src/profile_viewer.rs b/crates/cairo-profiler/src/profile_viewer.rs index 5a51be5..5618d03 100644 --- a/crates/cairo-profiler/src/profile_viewer.rs +++ b/crates/cairo-profiler/src/profile_viewer.rs @@ -20,7 +20,7 @@ struct FunctionProfile { } // we only care about two decimal places, so we do not really care about potential precision loss -#[allow(clippy::cast_precision_loss)] +#[expect(clippy::cast_precision_loss)] fn get_profile_data( profile: &Profile, sample_name: &str, diff --git a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs index 26eec72..7019cd1 100644 --- a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs +++ b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs @@ -44,7 +44,7 @@ impl AddAssign for Steps { } /// Collects profiling info of the current run using the trace. -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub fn collect_function_level_profiling_info( program: &Program, casm_debug_info: &CairoProgramDebugInfo,