Commit 48bf1322 authored by Maria Matejka's avatar Maria Matejka
Browse files

Introducing an universal temporary linpool flushed after every task

parent 2e8b8bfc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ ev_run_list(event_list *l)
	io_log_event(e->hook, e->data);

      ev_run(e);
      tmp_flush();
    }

  return !EMPTY_LIST(*l);
@@ -184,6 +185,7 @@ ev_run_list_limited(event_list *l, uint limit)
	io_log_event(e->hook, e->data);

      ev_run(e);
      tmp_flush();
      limit--;
    }

+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ struct linpool {
  uint chunk_size, threshold, total, total_large;
};

_Thread_local linpool *tmp_linpool;

static void lp_free(resource *);
static void lp_dump(resource *);
static resource *lp_lookup(resource *, unsigned long);
+1 −0
Original line number Diff line number Diff line
@@ -273,6 +273,7 @@ resource_init(void)
  root_pool.r.class = &pool_class;
  root_pool.name = "Root";
  init_list(&root_pool.inside);
  tmp_init(&root_pool);
}

/**
+9 −0
Original line number Diff line number Diff line
@@ -79,6 +79,15 @@ void lp_flush(linpool *); /* Free everything, but leave linpool */
void lp_save(linpool *m, lp_state *p);		/* Save state */
void lp_restore(linpool *m, lp_state *p);	/* Restore state */

extern _Thread_local linpool *tmp_linpool;	/* Temporary linpool autoflushed regularily */

#define tmp_alloc(sz)	lp_alloc(tmp_linpool, sz)
#define tmp_allocu(sz)	lp_allocu(tmp_linpool, sz)
#define tmp_allocz(sz)	lp_allocz(tmp_linpool, sz)

#define tmp_init(p)	tmp_linpool = lp_new_default(p)
#define tmp_flush()	lp_flush(tmp_linpool)

extern const int lp_chunk_size;
#define LP_GAS		    1024
#define LP_GOOD_SIZE(x)	    (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size)
+1 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ timers_fire(struct timeloop *loop)
      io_log_event(t->hook, t->data);

    t->hook(t);
    tmp_flush();
  }
}

Loading