static void parse_camlrunparam(void)
{
  char *opt = getenv ("OCAMLRUNPARAM");
  uintnat p;

  if (opt == NULL) opt = getenv ("CAMLRUNPARAM");

  if (opt != NULL){
    while (*opt != '\0'){
      switch (*opt++){
      case 'a': scanmult (opt, &p); caml_set_allocation_policy (p); break;
      case 'b': caml_record_backtrace(Val_true); break;
      case 'h': scanmult (opt, &heap_size_init); break;
      case 'i': scanmult (opt, &heap_chunk_init); break;
      case 'l': scanmult (opt, &max_stack_init); break;
      case 'o': scanmult (opt, &percent_free_init); break;
      case 'O': scanmult (opt, &max_percent_free_init); break;
      case 'p': caml_parser_trace = 1; break;
      /* case 'R': see stdlib/hashtbl.mli */
      case 's': scanmult (opt, &minor_heap_init); break;
#ifdef DEBUG
      case 't': caml_trace_flag = 1; break;
#endif
      case 'v': scanmult (opt, &caml_verb_gc); break;
      }
    }
  }
}
Esempio n. 2
0
static void parse_camlrunparam(void)
{
#if defined(__FreeBSD__) && defined(_KERNEL)
  char *opt;
  uintnat p;

  opt = get_rtparams();
#else
  char *opt = getenv ("OCAMLRUNPARAM");
  uintnat p;

  if (opt == NULL) opt = getenv ("CAMLRUNPARAM");
#endif

  if (opt != NULL){
    while (*opt != '\0'){
      switch (*opt++){
      case 's': scanmult (opt, &minor_heap_init); break;
      case 'i': scanmult (opt, &heap_chunk_init); break;
      case 'h': scanmult (opt, &heap_size_init); break;
      case 'l': scanmult (opt, &max_stack_init); break;
      case 'o': scanmult (opt, &percent_free_init); break;
      case 'O': scanmult (opt, &max_percent_free_init); break;
      case 'v': scanmult (opt, &caml_verb_gc); break;
      case 'b': caml_record_backtrace(Val_true); break;
      case 'p': caml_parser_trace = 1; break;
      case 'a': scanmult (opt, &p); caml_set_allocation_policy (p); break;
      }
    }
  }
}
Esempio n. 3
0
CAMLprim value caml_gc_set(value v)
{
    uintnat newpf, newpm;
    asize_t newheapincr;
    asize_t newminsize;
    uintnat oldpolicy;

    caml_verb_gc = Long_val (Field (v, 3));

#ifndef NATIVE_CODE
    caml_change_max_stack_size (Long_val (Field (v, 5)));
#endif

    newpf = norm_pfree (Long_val (Field (v, 2)));
    if (newpf != caml_percent_free) {
        caml_percent_free = newpf;
        caml_gc_message (0x20, "New space overhead: %d%%\n", caml_percent_free);
    }

    newpm = norm_pmax (Long_val (Field (v, 4)));
    if (newpm != caml_percent_max) {
        caml_percent_max = newpm;
        caml_gc_message (0x20, "New max overhead: %d%%\n", caml_percent_max);
    }

    newheapincr = Bsize_wsize (norm_heapincr (Long_val (Field (v, 1))));
    if (newheapincr != caml_major_heap_increment) {
        caml_major_heap_increment = newheapincr;
        caml_gc_message (0x20, "New heap increment size: %luk bytes\n",
                         caml_major_heap_increment/1024);
    }
    oldpolicy = caml_allocation_policy;
    caml_set_allocation_policy (Long_val (Field (v, 6)));
    if (oldpolicy != caml_allocation_policy) {
        caml_gc_message (0x20, "New allocation policy: %d\n",
                         caml_allocation_policy);
    }

    /* Minor heap size comes last because it will trigger a minor collection
       (thus invalidating [v]) and it can raise [Out_of_memory]. */
    newminsize = norm_minsize (Bsize_wsize (Long_val (Field (v, 0))));
    if (newminsize != caml_minor_heap_size) {
        caml_gc_message (0x20, "New minor heap size: %luk bytes\n",
                         newminsize/1024);
        caml_set_minor_heap_size (newminsize);
    }
    return Val_unit;
}
Esempio n. 4
0
CAMLprim value caml_gc_set(value v)
{
  uintnat newpf, newpm;
  asize_t newheapincr;
  asize_t newminwsz;
  uintnat oldpolicy;
  CAML_INSTR_SETUP (tmr, "");

  caml_verb_gc = Long_val (Field (v, 3));

#ifndef NATIVE_CODE
  caml_change_max_stack_size (Long_val (Field (v, 5)));
#endif

  newpf = norm_pfree (Long_val (Field (v, 2)));
  if (newpf != caml_percent_free){
    caml_percent_free = newpf;
    caml_gc_message (0x20, "New space overhead: %d%%\n", caml_percent_free);
  }

  newpm = norm_pmax (Long_val (Field (v, 4)));
  if (newpm != caml_percent_max){
    caml_percent_max = newpm;
    caml_gc_message (0x20, "New max overhead: %d%%\n", caml_percent_max);
  }

  newheapincr = Long_val (Field (v, 1));
  if (newheapincr != caml_major_heap_increment){
    caml_major_heap_increment = newheapincr;
    if (newheapincr > 1000){
      caml_gc_message (0x20, "New heap increment size: %luk words\n",
                       caml_major_heap_increment/1024);
    }else{
      caml_gc_message (0x20, "New heap increment size: %lu%%\n",
                       caml_major_heap_increment);
    }
  }
  oldpolicy = caml_allocation_policy;
  caml_set_allocation_policy (Long_val (Field (v, 6)));
  if (oldpolicy != caml_allocation_policy){
    caml_gc_message (0x20, "New allocation policy: %d\n",
                     caml_allocation_policy);
  }

  /* This field was added in 4.03.0. */
  if (Wosize_val (v) >= 8){
    int old_window = caml_major_window;
    caml_set_major_window (norm_window (Long_val (Field (v, 7))));
    if (old_window != caml_major_window){
      caml_gc_message (0x20, "New smoothing window size: %d\n",
                       caml_major_window);
    }
  }

    /* Minor heap size comes last because it will trigger a minor collection
       (thus invalidating [v]) and it can raise [Out_of_memory]. */
  newminwsz = norm_minsize (Long_val (Field (v, 0)));
  if (newminwsz != caml_minor_heap_wsz){
    caml_gc_message (0x20, "New minor heap size: %luk words\n",
                     newminwsz / 1024);
    caml_set_minor_heap_size (Bsize_wsize (newminwsz));
  }
  CAML_INSTR_TIME (tmr, "explicit/gc_set");
  return Val_unit;
}