You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dave Hill <dd...@laurel.zk3.dec.com> on 2000/07/16 18:41:14 UTC

Calculating a scoreboard fudge factor

Rob,
	here is a set of diffs that implement part of that fudge factor
calculation for scoreboard. I only implemented the part that I could 
build and test, so there are probably some other branchs of apr 
that may need a change.

I added a routine into mm to return a padded user size. The extra two
(long) words in the pad calculation are needed because of some 
rounding that it done in the align to word calculations (I think).
The result it that for Alpha, 32 bytes get added and not the 24 I 
had originally thought.

I see in the mm thank you doc that you have a working relation with
the author, I will leave it to you to feed this back to him. It is 
really up to him if he would add/support the routine, although I do
think it is needed if you don't want to was shm space.

Of course the 80 bytes I hacked in are not far off from the 64 needed :-)

Dave 

*** ./lib/apr/include/apr_shmem.h.orig	Sun Jul 16 11:42:26 2000
--- ./lib/apr/include/apr_shmem.h	Sun Jul 16 11:45:19 2000
***************
*** 91,96 ****
--- 91,108 ----
  
  /*
  
+ =head1 ap_size_t ap_shm_chunksize(ap_size_t reqsize)
+ 
+ B<Return padded size for use with ap_shm_init>
+ 
+     arg 1) The required size of a shared memory allocation
+ 
+ =cut
+  */
+ ap_size_t ap_shm_chunksize(ap_size_t reqsize);
+ 
+ /*
+ 
  =head1 ap_status_t ap_shm_destroy(ap_shmem_t *m)
  
  B<Destroy the shared memory block.>
*** ./lib/apr/shmem/unix/mm/mm.h.orig	Sun Jul 16 11:24:05 2000
--- ./lib/apr/shmem/unix/mm/mm.h	Sun Jul 16 11:33:50 2000
***************
*** 365,370 ****
--- 365,371 ----
  size_t  mm_core_maxsegsize(void);
  size_t  mm_core_align2page(size_t size);
  size_t  mm_core_align2word(size_t size);
+ size_t  mm_core_chunksize(size_t usize);
  
  /* Internal Library API */
  void    mm_lib_error_set(unsigned int, const char *str);
*** ./lib/apr/shmem/unix/mm/mm_alloc.c.orig	Sun Jul 16 12:28:12 2000
--- ./lib/apr/shmem/unix/mm/mm_alloc.c	Sun Jul 16 12:22:18 2000
***************
*** 282,287 ****
--- 282,297 ----
  }
  
  /*
+  * return a chunk size to use based on a users size. This is
+  * so a user can estimate total size for mm_create
+  */
+ size_t mm_core_chunksize(size_t usize)
+ {
+     return (usize ? 
+ 	mm_core_align2word(SIZEOF_mem_chunk+2*SIZEOF_mem_word+usize) : 0);
+ }
+ 
+ /*
   * Allocate a chunk of memory
   */
  void *mm_malloc(MM *mm, size_t usize)
*** ./lib/apr/shmem/unix/shmem.c.orig	Sun Jul 16 11:30:04 2000
--- ./lib/apr/shmem/unix/shmem.c	Sun Jul 16 11:35:06 2000
***************
*** 61,66 ****
--- 61,70 ----
      MM *mm;
  };
  
+ ap_size_t ap_shm_chunk_size(ap_size_t usize) {
+     return(mm_core_chunksize(usize));
+ }
+ 
  ap_status_t ap_shm_init(struct shmem_t **m, ap_size_t reqsize, const char *file, ap_pool_t *cont)
  {
      MM *newmm = mm_create(reqsize, file);
*** ./modules/mpm/mpmt_pthread/scoreboard.c.orig	Thu Jul 13 17:48:58 2000
--- ./modules/mpm/mpmt_pthread/scoreboard.c	Sun Jul 16 12:00:30 2000
***************
*** 104,110 ****
      const char *fname;
  
      fname = ap_server_root_relative(p, ap_scoreboard_fname);
!     if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) {
          ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
                      ap_server_argv0);
          perror(buf);
--- 104,117 ----
      const char *fname;
  
      fname = ap_server_root_relative(p, ap_scoreboard_fname);
! ap_snprintf(buf, sizeof(buf), "sb size %d v %d\n",SCOREBOARD_SIZE, ap_shm_chunk_size(SCOREBOARD_SIZE));
! perror(buf);
! ap_snprintf(buf, sizeof(buf), "nsb size %d v %d\n",NEW_SCOREBOARD_SIZE, ap_shm_chunk_size(NEW_SCOREBOARD_SIZE));
! perror(buf);
!     if (ap_shm_init(&scoreboard_shm, 
! 	    ap_shm_chunk_size(SCOREBOARD_SIZE) + 
! 	    ap_shm_chunk_size(NEW_SCOREBOARD_SIZE), 
! 	    fname, p) != APR_SUCCESS) {
          ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
                      ap_server_argv0);
          perror(buf);
+-------------------------------------------------------------+
Dave Hill                             Unix Software Group
Mailstop: ZKO3-3/Y15                  
Digital Equipment Corp.               (603) 884-2985
110 Spit Brook Road         /\_/\     enet: ddhill@zk3.dec.com
Nashua, NH 03062-2698       (0_0)     
+-----------------------oOO--(_)--OOo-------------------------+


Re: Calculating a scoreboard fudge factor

Posted by dean gaudet <dg...@arctic.org>.
huh?  why isn't this extra size foo hidden beneath the ap_shm interface?

-dean

On Sun, 16 Jul 2000, Dave Hill wrote:

> 
> Rob,
> 	here is a set of diffs that implement part of that fudge factor
> calculation for scoreboard. I only implemented the part that I could 
> build and test, so there are probably some other branchs of apr 
> that may need a change.
> 
> I added a routine into mm to return a padded user size. The extra two
> (long) words in the pad calculation are needed because of some 
> rounding that it done in the align to word calculations (I think).
> The result it that for Alpha, 32 bytes get added and not the 24 I 
> had originally thought.
> 
> I see in the mm thank you doc that you have a working relation with
> the author, I will leave it to you to feed this back to him. It is 
> really up to him if he would add/support the routine, although I do
> think it is needed if you don't want to was shm space.
> 
> Of course the 80 bytes I hacked in are not far off from the 64 needed :-)
> 
> Dave 
> 
> *** ./lib/apr/include/apr_shmem.h.orig	Sun Jul 16 11:42:26 2000
> --- ./lib/apr/include/apr_shmem.h	Sun Jul 16 11:45:19 2000
> ***************
> *** 91,96 ****
> --- 91,108 ----
>   
>   /*
>   
> + =head1 ap_size_t ap_shm_chunksize(ap_size_t reqsize)
> + 
> + B<Return padded size for use with ap_shm_init>
> + 
> +     arg 1) The required size of a shared memory allocation
> + 
> + =cut
> +  */
> + ap_size_t ap_shm_chunksize(ap_size_t reqsize);
> + 
> + /*
> + 
>   =head1 ap_status_t ap_shm_destroy(ap_shmem_t *m)
>   
>   B<Destroy the shared memory block.>
> *** ./lib/apr/shmem/unix/mm/mm.h.orig	Sun Jul 16 11:24:05 2000
> --- ./lib/apr/shmem/unix/mm/mm.h	Sun Jul 16 11:33:50 2000
> ***************
> *** 365,370 ****
> --- 365,371 ----
>   size_t  mm_core_maxsegsize(void);
>   size_t  mm_core_align2page(size_t size);
>   size_t  mm_core_align2word(size_t size);
> + size_t  mm_core_chunksize(size_t usize);
>   
>   /* Internal Library API */
>   void    mm_lib_error_set(unsigned int, const char *str);
> *** ./lib/apr/shmem/unix/mm/mm_alloc.c.orig	Sun Jul 16 12:28:12 2000
> --- ./lib/apr/shmem/unix/mm/mm_alloc.c	Sun Jul 16 12:22:18 2000
> ***************
> *** 282,287 ****
> --- 282,297 ----
>   }
>   
>   /*
> +  * return a chunk size to use based on a users size. This is
> +  * so a user can estimate total size for mm_create
> +  */
> + size_t mm_core_chunksize(size_t usize)
> + {
> +     return (usize ? 
> + 	mm_core_align2word(SIZEOF_mem_chunk+2*SIZEOF_mem_word+usize) : 0);
> + }
> + 
> + /*
>    * Allocate a chunk of memory
>    */
>   void *mm_malloc(MM *mm, size_t usize)
> *** ./lib/apr/shmem/unix/shmem.c.orig	Sun Jul 16 11:30:04 2000
> --- ./lib/apr/shmem/unix/shmem.c	Sun Jul 16 11:35:06 2000
> ***************
> *** 61,66 ****
> --- 61,70 ----
>       MM *mm;
>   };
>   
> + ap_size_t ap_shm_chunk_size(ap_size_t usize) {
> +     return(mm_core_chunksize(usize));
> + }
> + 
>   ap_status_t ap_shm_init(struct shmem_t **m, ap_size_t reqsize, const char *file, ap_pool_t *cont)
>   {
>       MM *newmm = mm_create(reqsize, file);
> *** ./modules/mpm/mpmt_pthread/scoreboard.c.orig	Thu Jul 13 17:48:58 2000
> --- ./modules/mpm/mpmt_pthread/scoreboard.c	Sun Jul 16 12:00:30 2000
> ***************
> *** 104,110 ****
>       const char *fname;
>   
>       fname = ap_server_root_relative(p, ap_scoreboard_fname);
> !     if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) {
>           ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
>                       ap_server_argv0);
>           perror(buf);
> --- 104,117 ----
>       const char *fname;
>   
>       fname = ap_server_root_relative(p, ap_scoreboard_fname);
> ! ap_snprintf(buf, sizeof(buf), "sb size %d v %d\n",SCOREBOARD_SIZE, ap_shm_chunk_size(SCOREBOARD_SIZE));
> ! perror(buf);
> ! ap_snprintf(buf, sizeof(buf), "nsb size %d v %d\n",NEW_SCOREBOARD_SIZE, ap_shm_chunk_size(NEW_SCOREBOARD_SIZE));
> ! perror(buf);
> !     if (ap_shm_init(&scoreboard_shm, 
> ! 	    ap_shm_chunk_size(SCOREBOARD_SIZE) + 
> ! 	    ap_shm_chunk_size(NEW_SCOREBOARD_SIZE), 
> ! 	    fname, p) != APR_SUCCESS) {
>           ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
>                       ap_server_argv0);
>           perror(buf);
> +-------------------------------------------------------------+
> Dave Hill                             Unix Software Group
> Mailstop: ZKO3-3/Y15                  
> Digital Equipment Corp.               (603) 884-2985
> 110 Spit Brook Road         /\_/\     enet: ddhill@zk3.dec.com
> Nashua, NH 03062-2698       (0_0)     
> +-----------------------oOO--(_)--OOo-------------------------+
> 
>