Branch: Tag:


2013-06-12 15:46:22 by Per Hedbor <>

[performance] Do not use block-alloc for pike_frame and catch_context

They are too important for code execution speed.

struct pike_frames are allocated in chunks but not free:d until the
program exists. This is basically just like the normal stack, and for
all but the most extreme of recursive programs this is not really an
issue. And for those programs the only loss now is that we are not
returning the frame memory to the system, we are actually using less
memory at peak.

The catch_context structures (that are fairly large, anyway, 80 bytes
on my machine) are simply allocated using malloc, and up to 100 free
ones are kept in a list for quick use.

748:    * ordinary code. */   #define FAST_CHECK_THREADS_ON_BRANCH() fast_check_threads_etc (8)    - #include "block_alloc_h.h" +    /* Prototypes begin here */   void push_sp_mark(void);   ptrdiff_t pop_sp_mark(void);
763:   void reset_evaluator(void);   struct backlog;   void dump_backlog(void); - BLOCK_ALLOC (catch_context, 0); - BLOCK_ALLOC(pike_frame,128); + struct catch_context *alloc_catch_context(void); + PMOD_EXPORT void really_free_catch_context( struct catch_context *data ); + PMOD_EXPORT void really_free_pike_frame( struct pike_frame *X ); + void count_memory_in_catch_contexts(size_t*, size_t*); + void count_memory_in_pike_frames(size_t*, size_t*);    -  + /*BLOCK_ALLOC (catch_context, 0);*/ + /*BLOCK_ALLOC(pike_frame,128);*/ +    #ifdef PIKE_USE_MACHINE_CODE   void call_check_threads_etc();   #if defined(OPCODE_INLINE_BRANCH) || defined(INS_F_JUMP) || \
784:      PMOD_EXPORT void find_external_context(struct external_variable_context *loc,    int arg2); + struct pike_frame *alloc_pike_frame(void);   void really_free_pike_scope(struct pike_frame *scope);   int low_mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2);   void low_return(void);