This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What's after guile-1.4? (was: Re: Questions... I am new to scheme)


Maciej Stachowiak <mstachow@mit.edu> writes:

> jimb@red-bean.com writes:
> > 
> > As far as Guile's size is concerned:
> > 
> > What we're trying to address here is not really a technical issue.
> > It's more of a psychological one: developers will hesitate to include
> > Guile in their applications if they feel, on a gut level, that it's
> > too large.
> > 
> 
> Actually, I believe the runtime memory consumption of Guile upon
> startup is a problematic technical issue. It causes the memory
> consumption of a stock copy of scwm with an empty scwmrc and no Scheme
> modules loaded to be much larger (1.5 to 2.5 times larger depending on
> the platform) than the corresponding fvwm2 memory image, when it
> really shouldn't be, since a general-purpose language should allow for
> much smaller code size for the primitives and thus not much greater
> memory usage in the no-config case. Part of this is because we have
> added a lot of features to scwm that are not in fvwm, but memory image
> was much bigger even when core code size was smaller (and this will
> probably happen again when we become even more aggressive about moving
> things from the core to loadable modules).

A big part of this is the way that the current gc gets memory.  The
default initial heap, for example, is 32768L*sizeof(scm_cell), and if
it can get that, each time it allocates a new segment, it gets the
heap size * 2 (this is actually a bug, it shouldn't be doing that if
it can get the size of the initial heap segment, I've appended a patch
against the current snapshot). So, if you create a large amount of
garbage that lives through one collection, you end up doubling the
size of the heap, which is not a very good idea in terms of memory
usage (for the rgc, and eventually the gengc, I've completely removed
the expmem thing).
 
> Now, arguably a 3 or 4 meg window manager image vs. a 1 or 2 meg total
> usage is not that bad in this day and age, but it pains me to waste
> memory unnecessarily. It also pains me to see people struggle with an
> ad-hoc config language because they believe it saves a lot of memory.
> 
> However, I think the main cause of the problem is boot-9.scm, not
> libguile. Now, obviously, there are many bits there that the module
> system depends on and can't be moved out until the Great Module System
> Rewrite, but I think some stuff can be safely consigned to other
> modules.

It definately should not be creating that much garbage at startup.

> Jim, would you accept changes to move some of the code from boot-9,
> such as accessors and non-polymorphic aliases for the posix and
> network procedures (I'll ask for confirmation on other apparently
> unnecessary things) into their own modules? Using Mikael's recent
> autoload stuff this can be a zero-user-impact change but I think the
> stuff I exlicitly mentioned is not worthy of such treatment.
> 
>  - Maciej
> 
> 

ChangeLog:
1998-12-10  Greg Harvey  <Greg.Harvey@thezone.net>

	* gc.c (scm_init_storage): changed the expmem thing to work as
	advertised. 


patch:
Index: libguile/gc.c
===================================================================
RCS file: /egcs/carton/cvsfiles/guile/guile-core/libguile/gc.c,v
retrieving revision 1.39
diff -c -r1.39 gc.c
*** gc.c	1998/12/05 18:52:12	1.39
--- gc.c	1998/12/10 18:46:01
***************
*** 1862,1876 ****
    if (0L == init_heap_size)
      init_heap_size = SCM_INIT_HEAP_SIZE;
    j = init_heap_size;
!   if ((init_heap_size != j)
!       || !init_heap_seg ((SCM_CELLPTR) malloc (j), j, 1, &scm_freelist))
      {
!       j = SCM_HEAP_SEG_SIZE;
!       if (!init_heap_seg ((SCM_CELLPTR) malloc (j), j, 1, &scm_freelist))
! 	return 1;
      }
-   else
-     scm_expmem = 1;
    scm_heap_org = CELL_UP (scm_heap_table[0].bounds[0]);
    /* scm_hplims[0] can change. do not remove scm_heap_org */
    if (!(scm_weak_vectors = (SCM *) malloc ((scm_weak_size = 32) * sizeof(SCM *))))
--- 1862,1876 ----
    if (0L == init_heap_size)
      init_heap_size = SCM_INIT_HEAP_SIZE;
    j = init_heap_size;
!   
!   if (init_heap_size != j) {
!     j = SCM_HEAP_SEG_SIZE;
!     scm_expmem = 1;
!   }
!   if (!init_heap_seg ((SCM_CELLPTR) malloc (j), j, 1, &scm_freelist))
      {
!       return 1;
      }
    scm_heap_org = CELL_UP (scm_heap_table[0].bounds[0]);
    /* scm_hplims[0] can change. do not remove scm_heap_org */
    if (!(scm_weak_vectors = (SCM *) malloc ((scm_weak_size = 32) * sizeof(SCM *))))

-- 
Greg