Skip to content

Commit

Permalink
clean up logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Oct 25, 2023
1 parent 2516907 commit 9dedcc5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions crates/steel-core/src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl Compiler {
path: Option<PathBuf>,
sources: &mut Sources,
) -> Result<RawProgramWithSymbols> {
log::info!(target: "expansion-phase", "Expanding macros -> phase 0");
log::debug!(target: "expansion-phase", "Expanding macros -> phase 0");

let mut expanded_statements =
self.expand_expressions(exprs, path, sources, builtin_modules.clone())?;
Expand All @@ -613,14 +613,14 @@ impl Compiler {
);
}

log::info!(target: "expansion-phase", "Expanding macros -> phase 1");
log::debug!(target: "expansion-phase", "Expanding macros -> phase 1");

expanded_statements = expanded_statements
.into_iter()
.map(|x| expand_kernel(x, self.kernel.as_mut(), builtin_modules.clone()))
.collect::<Result<Vec<_>>>()?;

log::info!(target: "expansion-phase", "Beginning constant folding");
log::debug!(target: "expansion-phase", "Beginning constant folding");

let mut expanded_statements =
self.apply_const_evaluation(constants.clone(), expanded_statements, false)?;
Expand All @@ -646,7 +646,7 @@ impl Compiler {

// debug!("About to expand defines");

log::info!(target: "expansion-phase", "Flattening begins, converting internal defines to let expressions");
log::debug!(target: "expansion-phase", "Flattening begins, converting internal defines to let expressions");

let mut expanded_statements = flatten_begins_and_expand_defines(expanded_statements);

Expand All @@ -673,7 +673,7 @@ impl Compiler {
);
}

log::info!(target: "expansion-phase", "Expanding multiple arity functions");
log::debug!(target: "expansion-phase", "Expanding multiple arity functions");

// TODO - make sure I want to keep this
let expanded_statements =
Expand All @@ -688,7 +688,7 @@ impl Compiler {
// Here we're gonna do the constant evaluation pass, using the kernel for execution of the
// constant functions w/ memoization:

log::info!(target: "expansion-phase", "Generating instructions");
log::debug!(target: "expansion-phase", "Generating instructions");

let instructions = self.generate_instructions_for_executable(expanded_statements)?;

Expand Down
10 changes: 5 additions & 5 deletions crates/steel-core/src/steel_vm/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl Engine {
/// Has access to primitives and syntax rules, but will not defer to a child
/// kernel in the compiler
pub(crate) fn new_kernel() -> Self {
log::info!(target:"kernel", "Instantiating a new kernel");
log::debug!(target:"kernel", "Instantiating a new kernel");

let mut vm = Engine {
virtual_machine: SteelThread::new(),
Expand All @@ -241,15 +241,15 @@ impl Engine {
vm.compile_and_run_raw_program(crate::steel_vm::primitives::ALL_MODULES)
.unwrap();

log::info!(target:"kernel", "Registered modules in the kernel!");
log::debug!(target:"kernel", "Registered modules in the kernel!");

let core_libraries = [crate::stdlib::PRELUDE, crate::stdlib::DISPLAY];

for core in core_libraries.into_iter() {
vm.compile_and_run_raw_program(core).unwrap();
}

log::info!(target: "kernel", "Loaded prelude in the kernel!");
log::debug!(target: "kernel", "Loaded prelude in the kernel!");

vm
}
Expand Down Expand Up @@ -278,7 +278,7 @@ impl Engine {
return Engine::new_kernel();
}

log::info!(target:"kernel", "Instantiating a new kernel");
log::debug!(target:"kernel", "Instantiating a new kernel");

let mut vm = Engine {
virtual_machine: SteelThread::new(),
Expand All @@ -303,7 +303,7 @@ impl Engine {
// vm.run_raw_program_from_exprs(ast).unwrap();
}

log::info!(target: "kernel", "Loaded prelude in the kernel!");
log::debug!(target: "kernel", "Loaded prelude in the kernel!");

let sources = vm.sources.clone();

Expand Down
4 changes: 2 additions & 2 deletions crates/steel-core/src/steel_vm/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2592,14 +2592,14 @@ impl<'a> VmCore<'a> {
.closure_interner
.get(&closure_id)
{
log::info!("Fetching closure from cache");
log::trace!("Fetching closure from cache");

let mut prototype = prototype.clone();
prototype.set_captures(captures);
prototype.set_heap_allocated(heap_vars);
prototype
} else {
log::info!("Constructing closure for the first time");
log::trace!("Constructing closure for the first time");

debug_assert!(self.instructions[forward_index - 1].op_code == OpCode::ECLOSURE);

Expand Down
20 changes: 10 additions & 10 deletions crates/steel-core/src/values/closed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Heap {
let memory_size = self.memory.len() + self.vectors.len();

if memory_size > self.threshold {
log::info!(target: "gc", "Freeing memory");
log::debug!(target: "gc", "Freeing memory");

let original_length = memory_size;

Expand All @@ -188,26 +188,26 @@ impl Heap {
// sweep collection.
let mut changed = true;
while changed {
log::info!(target: "gc", "Small collection");
log::debug!(target: "gc", "Small collection");
let prior_len = self.memory.len() + self.vectors.len();
log::info!(target: "gc", "Previous length: {:?}", prior_len);
log::debug!(target: "gc", "Previous length: {:?}", prior_len);
self.memory.retain(|x| Rc::weak_count(x) > 0);
self.vectors.retain(|x| Rc::weak_count(x) > 0);
let after = self.memory.len() + self.vectors.len();
log::info!(target: "gc", "Objects freed: {:?}", prior_len - after);
log::debug!(target: "gc", "Objects freed: {:?}", prior_len - after);
changed = prior_len != after;
}

let post_small_collection_size = self.memory.len() + self.vectors.len();

// Mark + Sweep!
if post_small_collection_size as f64 > (0.25 * original_length as f64) {
log::info!(target: "gc", "---- Post small collection, running mark and sweep - heap size filled: {:?} ----", post_small_collection_size as f64 / original_length as f64);
log::debug!(target: "gc", "---- Post small collection, running mark and sweep - heap size filled: {:?} ----", post_small_collection_size as f64 / original_length as f64);

// TODO fix the garbage collector
self.mark_and_sweep(roots, live_functions, globals);
} else {
log::info!(target: "gc", "---- Skipping mark and sweep - heap size filled: {:?} ----", post_small_collection_size as f64 / original_length as f64);
log::debug!(target: "gc", "---- Skipping mark and sweep - heap size filled: {:?} ----", post_small_collection_size as f64 / original_length as f64);
}

// self.mark_and_sweep(roots, live_functions, globals);
Expand Down Expand Up @@ -236,7 +236,7 @@ impl Heap {
function_stack: impl Iterator<Item = &'a ByteCodeLambda>,
globals: impl Iterator<Item = &'a SteelVal>,
) {
log::info!(target: "gc", "Marking the heap");
log::debug!(target: "gc", "Marking the heap");

let mut context = MarkAndSweepContext {
queue: &mut self.mark_and_sweep_queue,
Expand Down Expand Up @@ -285,7 +285,7 @@ impl Heap {
// .collect::<Vec<_>>()
// );

log::info!(target: "gc", "--- Sweeping ---");
log::debug!(target: "gc", "--- Sweeping ---");
let prior_len = self.memory.len() + self.vectors.len();

// sweep
Expand All @@ -296,8 +296,8 @@ impl Heap {

let amount_freed = prior_len - after_len;

log::info!(target: "gc", "Freed objects: {:?}", amount_freed);
log::info!(target: "gc", "Objects alive: {:?}", after_len);
log::debug!(target: "gc", "Freed objects: {:?}", amount_freed);
log::debug!(target: "gc", "Objects alive: {:?}", after_len);

// put them back as unreachable
self.memory.iter().for_each(|x| x.borrow_mut().reset());
Expand Down

0 comments on commit 9dedcc5

Please sign in to comment.