Re: page sizes



copx wrote:

Yes. This optimizes the variables and hardware registers used to manage
the pages. None of their bits are wasted. User-level code doesn't need
these optimizations, so they pick array sizes with different conveniences.

"Doesn't need" is your opinion.

Welcome to USENET.

I am trying to squeeze a few more nanoseconds out of a programming language
interpreter. The documentation of malloc() on one of the platforms I am
targetting explicitly gives the advice to allocate powers of 2 to improve
performance. However, that is only true if the allocated blocks are <=
pagesize. Larger blocks allocate fastest if they are multiples of the page
size.

My opinion is also to not use malloc(). Write a custom allocator that
manages a heap of fixed-sized blocks. These will be several orders of
magnitude more efficient than a generic malloc(). Then, if you also
use block sizes of powers of two, you can manage them with very small
variables. But these will be slow to manipulate (splitting and
shifting), so you only optimize your footprint if you can pack them
all together.

But that's just my opinion, and you might not find it in all the books
and such about optimizing with C-style languages...

- it might vary for any conceivable reason, including odd bus
architectures.

Not on Redhad Linux x86/32. The official documentation specifies the page
size as 4096.

Oh, another of my opinions that was right. Darn!

I guess one could easily hack the system to set another size,
but one can assume that 99,9% of all users won't do this.

Far from "easy"...

--
Phlip
.



Relevant Pages

  • Re: page sizes
    ... these optimizations, so they pick array sizes with different conveniences. ... Larger blocks allocate fastest if they are multiples of the page ... The official documentation specifies the page ...
    (comp.programming)
  • Re: [PATCH rc1-mm 0/3] coredump: rfc
    ... So I am asking for yours opinion not only about correctness, ... also about usefulness. ... I think the optimizations are worthwhile, ...
    (Linux-Kernel)
  • Re: structure size limitation in VS C++ 6.0?
    ... In my opinion, there should be no problem if you allocate it on the heap. ...
    (microsoft.public.vstudio.development)
  • [PATCH rc1-mm 0/3] coredump: rfc
    ... It adds some optimizations, but ... complicates the code. ... So I am asking for yours opinion not only about correctness, ...
    (Linux-Kernel)
  • Re: looking for thoughts on the philosophy of optimizing compilers
    ... arranged to allow many optimizations to be performed safely. ... I think he probably meant the compiler you yourself wrote. ... The fact that I haven't built, say, my own car does not ... expression of opinion about lcc-win32. ...
    (comp.lang.c)