unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Aligned blocks management: obsolete?
@ 2011-12-12  8:11 Dmitry Antipov
  2011-12-12 13:13 ` Eli Zaretskii
  2011-12-12 18:38 ` Stefan Monnier
  0 siblings, 2 replies; 25+ messages in thread
From: Dmitry Antipov @ 2011-12-12  8:11 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

Is it still required to maintain the cache of aligned blocks
to workaround poor malloc behavior? I believe an attached
example should perform well (i.e. allocate ~4K blocks without
~4K holes between them) on top of any non-ancient glibc (no
ideas about other system malloc implementations, BTW).

Dmitry

[-- Attachment #2: aligned-alloc.c --]
[-- Type: text/plain, Size: 745 bytes --]

#include <stdio.h>
#include <stdlib.h>

#define BLOCKSZ 4096

int
main (int argc, char *argv[])
{
  int i, j;
  void *p;

  /* make some chaos in the heap */
  for (i = 0; i < 1000; i++)
    for (j = 0; j < 1024; j++)
      {
	p = malloc (j);
	if (((i + j) & 7) == 0)
	  free (p);
      }

  /* test */
  for (i = 0; i < 16; i++)
    if (!posix_memalign (&p, BLOCKSZ, BLOCKSZ - sizeof (long)))
      printf ("%p\n", p);
  printf ("--\n");

  /* make even more chaos with larger chunks */
  for (i = 0; i < 1000; i++)
    {
      p = malloc (i * 1000);
      if ((i & 7) == 0)
	free (p);
    }

  /* test again */
  for (i = 0; i < 16; i++)
    if (!posix_memalign (&p, BLOCKSZ, BLOCKSZ - sizeof (long)))
      printf ("%p\n", p);

  return 0;
}

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2012-07-04 13:11 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12  8:11 Aligned blocks management: obsolete? Dmitry Antipov
2011-12-12 13:13 ` Eli Zaretskii
2011-12-12 14:07   ` Dmitry Antipov
2011-12-12 18:11     ` Eli Zaretskii
2011-12-12 18:27     ` Paul Eggert
2012-06-19 16:51       ` Dmitry Antipov
2012-06-19 17:13         ` Eli Zaretskii
2012-06-19 21:34         ` Stefan Monnier
2012-06-20  6:47           ` Dmitry Antipov
2012-06-20 12:48             ` Stefan Monnier
2012-06-20 13:54               ` Dmitry Antipov
2012-06-20 15:41                 ` Stefan Monnier
2012-06-20 17:10                 ` Eli Zaretskii
2012-06-21  4:27                   ` Dmitry Antipov
2012-06-21 16:29                     ` Eli Zaretskii
2012-07-04  8:39                       ` Old topic(s) again [was: Re: Aligned blocks management: obsolete?] Dmitry Antipov
2012-07-04 13:11                         ` Stefan Monnier
2012-06-21 21:34                     ` Aligned blocks management: obsolete? Richard Stallman
2012-06-20 17:06             ` Eli Zaretskii
2012-06-21  3:30               ` Dmitry Antipov
2012-06-21 16:23                 ` Eli Zaretskii
2012-06-20 17:59             ` Wolfgang Jenkner
2012-06-21  3:12               ` Dmitry Antipov
2012-06-20  6:53         ` Paul Eggert
2011-12-12 18:38 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).