all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* malloc and alignment
@ 2003-06-16 14:38 Stefan Monnier
  2003-06-16 15:15 ` David Kastrup
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Stefan Monnier @ 2003-06-16 14:38 UTC (permalink / raw)



I'd like to try and get rid of the markbit on Lisp_Object values.
The idea is to scrape off a few more bits (I'd like to bump
maxint to 512MB instead of 128MB).  And I'd also like to represent
floats in 8bytes rather than 12.

So the idea is to use a separate bitmap, but in order to quickly
find the markbit corresponding to an object, we need to be able
to quickly find the bitmap for an arbitrary pointer.

The typical solution for this is to allocate things in chunks of
<power-of-2 here> such that you can get the base of the bitmap
by doing `ptrvalue & bitmask'.

But for this, I need to make sure things are properly aligned.
Currently alloc.c calls malloc to allocate blocks of about 8KB
which are then split into 1000 cons cells or floats or whatever.
So all we need is to make sure that those 8KB are properly aligned.
But how can I do that ?
It seems the only reliable way is to malloc 16KB and then waste
the 8KB that happen to be before/after the aligned part.

Should I just wrap malloc in my own malloc_aligned such that
malloc_aligned calls malloc to allocate chunks of say 1MB
and then gives them out in aligned packets of 8KB ?

Has anybody played with things like that and could share his/her
experience ?


	Stefan


PS: Of course, an alternative is to split my 8KB blocks into aligned
    subblocks of 256B: 31 cons cells (or floats) plus one 32bit integer
    for the bitmask.  This makes the bitmask access a tiny bit simpler
    since the bitmap is made of a single integer rather than an array
    of ints.  On another hand, it will waste a lot of cache space
    unless your cache lines are 256B long.

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

end of thread, other threads:[~2003-07-04 20:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-16 14:38 malloc and alignment Stefan Monnier
2003-06-16 15:15 ` David Kastrup
2003-06-16 15:39   ` Stefan Monnier
2003-06-16 15:59   ` Stefan Monnier
2003-06-17  4:57     ` Stephen J. Turnbull
2003-06-17  7:35       ` David Kastrup
2003-06-16 22:35 ` Miles Bader
2003-06-16 23:11   ` Stefan Monnier
2003-06-17  2:25     ` Miles Bader
2003-06-17  4:48 ` Stephen J. Turnbull
     [not found] ` <E19SJCe-0008Bb-Vp@fencepost.gnu.org>
2003-06-24 22:52   ` Stefan Monnier
     [not found]     ` <E19VGK5-0000CQ-F4@fencepost.gnu.org>
2003-06-27 23:17       ` Stefan Monnier
2003-06-27 23:47         ` Miles Bader
2003-06-29  2:30         ` Richard Stallman
2003-07-04 20:42           ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.