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

Change allow to expect #145

Merged
merged 4 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [

[workspace.package]
version = "0.8.0"
edition = "2021"
edition = "2024"


[workspace.dependencies]
Expand Down
21 changes: 15 additions & 6 deletions crates/cairo-profiler/src/profile_builder.rs
Original file line number Diff line number Diff line change
@@ -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"));
}
Expand All @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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() {
Expand All @@ -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"
)
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions crates/cairo-profiler/src/profile_viewer.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-profiler/src/sierra_loader.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -44,7 +44,7 @@ impl AddAssign<usize> 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,
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-profiler/tests/e2e.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading