Find the engine with the largest number of memories we can create on this machine.
(args: &Args, mpk: Enabled)
| 91 | /// Find the engine with the largest number of memories we can create on this |
| 92 | /// machine. |
| 93 | fn probe_engine_size(args: &Args, mpk: Enabled) -> Result<Pool> { |
| 94 | let mut search = ExponentialSearch::new(); |
| 95 | let mut mapped_bytes = 0; |
| 96 | while !search.done() { |
| 97 | match build_engine(&args, search.next(), mpk) { |
| 98 | Ok(rb) => { |
| 99 | // TODO: assert!(rb >= mapped_bytes); |
| 100 | mapped_bytes = rb; |
| 101 | search.record(true) |
| 102 | } |
| 103 | Err(e) => { |
| 104 | warn!("failed engine allocation, continuing search: {e:?}"); |
| 105 | search.record(false) |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | Ok(Pool { |
| 110 | num_memories: search.next(), |
| 111 | mapped_bytes, |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | #[derive(Debug)] |
| 116 | struct Pool { |