Skip to content

Move some hint logic to compile_hint #2219

@JulianGCalderon

Description

@JulianGCalderon

Currently compile_hint barely contains any logic.

fn compile_hint(
&self,
//Block of hint code as String
hint_code: &str,
//Ap Tracking Data corresponding to the Hint
ap_tracking_data: &ApTracking,
//Map from variable name to reference id number
//(may contain other variables aside from those used by the hint)
reference_ids: &HashMap<String, usize>,
//List of all references (key corresponds to element of the previous dictionary)
references: &[HintReference],
// Identifiers stored in the hint's program.
constants: Rc<HashMap<String, Felt252>>,
) -> Result<Box<dyn Any>, VirtualMachineError> {
Ok(any_box!(HintProcessorData {
code: hint_code.to_string(),
ap_tracking: ap_tracking_data.clone(),
ids_data: get_ids_data(reference_ids, references)?,
constants,
}))

We should investigate if there is logic that can be moved to the compilation step. The idea is to properly take advantage of compile_hint/execute_hint, instead of using compile_hint as a placeholder.

Some ideas:

  • All references are computed, regardless of whether they are used or not. This accounts for 7% of the execution
  • When executing a hint, we need to match the hint code. The match is really big, which could affect performance.
  • Constant lookup is being done on execution, but could be moved to compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance-related improvements or regressions

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions