From eb30ba59c4ca08c54a7dafbf5ade917e6714f990 Mon Sep 17 00:00:00 2001 From: Xavier Pinsach <10213118+xavi-pinsach@users.noreply.github.com> Date: Mon, 7 Oct 2024 09:18:29 +0000 Subject: [PATCH 1/3] improve output --- .../lib/std/rs/src/range_check/specified_ranges.rs | 4 +--- .../lib/std/rs/src/range_check/u16air.rs | 4 +--- pil2-components/lib/std/rs/src/range_check/u8air.rs | 4 +--- pil2-components/lib/std/rs/src/std.rs | 4 ++-- proofman/src/witness_component.rs | 13 +++++++------ 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs b/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs index 2f8f4f3e..d62876b2 100644 --- a/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs +++ b/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs @@ -59,8 +59,6 @@ impl SpecifiedRanges { // Update the multiplicity column self.update_multiplicity(drained_inputs); - - log::info!("{}: Updated inputs for AIR '{}'", Self::MY_NAME, "SpecifiedRanges"); } } @@ -85,7 +83,7 @@ impl SpecifiedRanges { set_hint_field(self.wcm.get_sctx(), air_instance, *hint, "reference", &mul[index - 1]); } - log::info!("{}: Drained inputs for AIR '{}'", Self::MY_NAME, "SpecifiedRanges"); + log::trace!("{}: ··· Drained inputs for AIR '{}'", Self::MY_NAME, "SpecifiedRanges"); } fn update_multiplicity(&self, drained_inputs: Vec<(Range, F)>) { diff --git a/pil2-components/lib/std/rs/src/range_check/u16air.rs b/pil2-components/lib/std/rs/src/range_check/u16air.rs index 98788a7a..cd3ffcb2 100644 --- a/pil2-components/lib/std/rs/src/range_check/u16air.rs +++ b/pil2-components/lib/std/rs/src/range_check/u16air.rs @@ -55,8 +55,6 @@ impl U16Air { // Update the multiplicity column self.update_multiplicity(drained_inputs); - - log::info!("{}: Updated inputs for AIR '{}'", Self::MY_NAME, "U16Air"); } } @@ -76,7 +74,7 @@ impl U16Air { let mul = &*self.mul.lock().unwrap(); set_hint_field(self.wcm.get_sctx(), air_instance, self.hint.load(Ordering::Acquire), "reference", mul); - log::info!("{}: Drained inputs for AIR '{}'", Self::MY_NAME, "U16Air"); + log::trace!("{}: ··· Drained inputs for AIR '{}'", Self::MY_NAME, "U16Air"); } fn update_multiplicity(&self, drained_inputs: Vec) { diff --git a/pil2-components/lib/std/rs/src/range_check/u8air.rs b/pil2-components/lib/std/rs/src/range_check/u8air.rs index 6e60f10a..8f2f92e4 100644 --- a/pil2-components/lib/std/rs/src/range_check/u8air.rs +++ b/pil2-components/lib/std/rs/src/range_check/u8air.rs @@ -52,8 +52,6 @@ impl U8Air { // Update the multiplicity column self.update_multiplicity(drained_inputs); - - log::info!("{}: Updated inputs for AIR '{}'", Self::MY_NAME, "U8Air"); } } @@ -73,7 +71,7 @@ impl U8Air { let mul = &*self.mul.lock().unwrap(); set_hint_field(self.wcm.get_sctx(), air_instance, self.hint.load(Ordering::Acquire), "reference", mul); - log::info!("{}: Drained inputs for AIR '{}'", Self::MY_NAME, "U8Air"); + log::trace!("{}: ··· Drained inputs for AIR '{}'", Self::MY_NAME, "U8Air"); } fn update_multiplicity(&self, drained_inputs: Vec) { diff --git a/pil2-components/lib/std/rs/src/std.rs b/pil2-components/lib/std/rs/src/std.rs index 524920db..70c868c2 100644 --- a/pil2-components/lib/std/rs/src/std.rs +++ b/pil2-components/lib/std/rs/src/std.rs @@ -18,12 +18,12 @@ pub struct Std { } impl Std { - const _MY_NAME: &'static str = "STD"; + const MY_NAME: &'static str = "STD "; pub fn new(wcm: Arc>, rc_air_data: Option>) -> Arc { let mode = StdMode::new(ModeName::Standard, None, 10); - log::info!("The STD has been initialized on mode {}", mode.name); + log::info!("{}: ··· The PIL2 STD library has been initialized on mode {}", Self::MY_NAME, mode.name); // Instantiate the STD components StdProd::new(mode.clone(), wcm.clone()); diff --git a/proofman/src/witness_component.rs b/proofman/src/witness_component.rs index fe7ca258..97694446 100644 --- a/proofman/src/witness_component.rs +++ b/proofman/src/witness_component.rs @@ -7,12 +7,13 @@ pub trait WitnessComponent: Send + Sync { fn calculate_witness( &self, - stage: u32, - air_instance: Option, - pctx: Arc>, - ectx: Arc, - sctx: Arc, - ); + _stage: u32, + _air_instance: Option, + _pctx: Arc>, + _ectx: Arc, + _sctx: Arc, + ) { + } fn end_proof(&self) {} } From 75dd8456fdcc06c0131b72280b19e0d62bc3dcef Mon Sep 17 00:00:00 2001 From: Xavier Pinsach <10213118+xavi-pinsach@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:36:19 +0000 Subject: [PATCH 2/3] add create buffer fast function --- .../lib/std/rs/src/range_check/specified_ranges.rs | 3 ++- pil2-components/lib/std/rs/src/range_check/u16air.rs | 3 ++- pil2-components/lib/std/rs/src/range_check/u8air.rs | 3 ++- proofman/src/proofman.rs | 8 ++++---- util/src/lib.rs | 11 +++++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs b/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs index d62876b2..4ea9c33a 100644 --- a/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs +++ b/pil2-components/lib/std/rs/src/range_check/specified_ranges.rs @@ -9,6 +9,7 @@ use proofman_common::{AirInstance, ExecutionCtx, ProofCtx, SetupCtx}; use proofman_hints::{ get_hint_field, get_hint_field_constant, get_hint_ids_by_name, set_hint_field, HintFieldOptions, HintFieldValue, }; +use proofman_util::create_buffer_fast; use crate::Range; @@ -210,7 +211,7 @@ impl WitnessComponent for SpecifiedRanges { let (buffer_size, _) = ectx.buffer_allocator.as_ref().get_buffer_info(&sctx, self.airgroup_id, self.air_id).unwrap(); - let buffer = vec![F::zero(); buffer_size as usize]; + let buffer = create_buffer_fast(buffer_size as usize); // Add a new air instance. Since Specified Ranges is a table, only this air instance is needed let mut air_instance = AirInstance::new(self.airgroup_id, self.air_id, None, buffer); diff --git a/pil2-components/lib/std/rs/src/range_check/u16air.rs b/pil2-components/lib/std/rs/src/range_check/u16air.rs index cd3ffcb2..1b7544c9 100644 --- a/pil2-components/lib/std/rs/src/range_check/u16air.rs +++ b/pil2-components/lib/std/rs/src/range_check/u16air.rs @@ -10,6 +10,7 @@ use proofman::{WitnessComponent, WitnessManager}; use proofman_common::{AirInstance, ExecutionCtx, ProofCtx, SetupCtx}; use proofman_hints::{get_hint_field, get_hint_ids_by_name, set_hint_field, HintFieldOptions, HintFieldValue}; +use proofman_util::create_buffer_fast; use std::sync::atomic::Ordering; const PROVE_CHUNK_SIZE: usize = 1 << 5; @@ -114,7 +115,7 @@ impl WitnessComponent for U16Air { let (buffer_size, _) = ectx.buffer_allocator.as_ref().get_buffer_info(&sctx, self.airgroup_id, self.air_id).unwrap(); - let buffer = vec![F::zero(); buffer_size as usize]; + let buffer = create_buffer_fast(buffer_size as usize); // Add a new air instance. Since U16Air is a table, only this air instance is needed let mut air_instance = AirInstance::new(self.airgroup_id, self.air_id, None, buffer); diff --git a/pil2-components/lib/std/rs/src/range_check/u8air.rs b/pil2-components/lib/std/rs/src/range_check/u8air.rs index 8f2f92e4..67cfe527 100644 --- a/pil2-components/lib/std/rs/src/range_check/u8air.rs +++ b/pil2-components/lib/std/rs/src/range_check/u8air.rs @@ -6,6 +6,7 @@ use p3_field::PrimeField; use proofman::{WitnessComponent, WitnessManager}; use proofman_common::{AirInstance, ExecutionCtx, ProofCtx, SetupCtx}; use proofman_hints::{get_hint_field, get_hint_ids_by_name, set_hint_field, HintFieldOptions, HintFieldValue}; +use proofman_util::create_buffer_fast; use std::sync::atomic::Ordering; const PROVE_CHUNK_SIZE: usize = 1 << 5; @@ -111,7 +112,7 @@ impl WitnessComponent for U8Air { let (buffer_size, _) = ectx.buffer_allocator.as_ref().get_buffer_info(&sctx, self.airgroup_id, self.air_id).unwrap(); - let buffer = vec![F::zero(); buffer_size as usize]; + let buffer = create_buffer_fast(buffer_size as usize); // Add a new air instance. Since U8Air is a table, only this air instance is needed let mut air_instance = AirInstance::new(self.airgroup_id, self.air_id, None, buffer); diff --git a/proofman/src/proofman.rs b/proofman/src/proofman.rs index cc243f28..a2b8a27a 100644 --- a/proofman/src/proofman.rs +++ b/proofman/src/proofman.rs @@ -230,7 +230,7 @@ impl ProofMan { } fn initialize_provers(sctx: Arc, provers: &mut Vec>>, pctx: Arc>) { - info!("{}: Initializing prover and creating buffers", Self::MY_NAME); + info!("{}: ··· INITIALIZING PROVER CLIENTS", Self::MY_NAME); timer_start!(INITIALIZING_PROVERS); for (prover_idx, air_instance) in pctx.air_instance_repo.air_instances.read().unwrap().iter().enumerate() { @@ -318,7 +318,7 @@ impl ProofMan { transcript: &mut FFITranscript, debug_mode: u64, ) { - info!("{}: Calculating challenges for stage {}", Self::MY_NAME, stage); + info!("{}: ··· CALCULATING CHALLENGES FOR STAGE {}", Self::MY_NAME, stage); let airgroups = proof_ctx.global_info.subproofs.clone(); for (airgroup_id, _airgroup) in airgroups.iter().enumerate() { if debug_mode != 0 { @@ -468,7 +468,7 @@ impl ProofMan { let mut air_groups: Vec<_> = air_instances.keys().collect(); air_groups.sort(); - info!("{}: >>> PROOF INSTANCES SUMMARY ------------------------", Self::MY_NAME); + info!("{}: --- PROOF INSTANCES SUMMARY ------------------------", Self::MY_NAME); info!("{}: ► {} Air instances found:", Self::MY_NAME, air_instances_repo.len()); for air_group in air_groups { let air_group_instances = air_instances.get(air_group).unwrap(); @@ -485,6 +485,6 @@ impl ProofMan { ); } } - info!("{}: <<< PROOF INSTANCES SUMMARY ------------------------", Self::MY_NAME); + info!("{}: --- PROOF INSTANCES SUMMARY ------------------------", Self::MY_NAME); } } diff --git a/util/src/lib.rs b/util/src/lib.rs index 029b51ed..b8434d5a 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -1,2 +1,13 @@ pub mod cli; pub mod timer_macro; + +use std::mem::MaybeUninit; + +pub fn create_buffer_fast(buffer_size: usize) -> Vec { + let mut buffer: Vec> = Vec::with_capacity(buffer_size); + unsafe { + buffer.set_len(buffer_size); + } + let buffer: Vec = unsafe { std::mem::transmute(buffer) }; + buffer +} From fd53126c8b1cf0b504137e01e513cbb83421ad1e Mon Sep 17 00:00:00 2001 From: Xavier Pinsach <10213118+xavi-pinsach@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:37:37 +0000 Subject: [PATCH 3/3] fix pil2-compiler version to pass the tests --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b49f6384..4641e68d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -159,7 +159,7 @@ jobs: with: repository: 0xPolygonHermez/pil2-compiler token: ${{ secrets.GITHUB_TOKEN }} - ref: develop + ref: 5e4185c07b717f27d627a4249e7665881593f32d path: pil2-compiler - name: Install pil2-compiler dependencies