A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-April/022168.html below:

[Python-Dev] pymalloc killer

[Python-Dev] pymalloc killerMarangozov, Vladimir (Vladimir) vmarangozov@optimay.com
Wed, 3 Apr 2002 16:50:19 +0200
[Tim, in obmalloc.c]

> #define ADDRESS_IN_RANGE(P, I) \
>         ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE)

Bravo! Very nice.

Now that the pool header is reduced in size by one slot, I can only
suggest a small optimization to get rid off the multiplication when
trying to extend the free list. Since you know the code by heart
already, this should be self explanatory. It's only 3 lines of code:

1) add a member in the pool struct, after capacity:

      uint lastoffset;               /* free list tail block offset */

2) In malloc, in the "try to extend the free list" block:

      size <<= ALIGNMENT_SHIFT;      /* block size */
      pool->lastoffset += size;
      pool->freeblock = (block *)pool + pool->lastoffset;

3) In the "init_pool" block:

      pool->capacity = ...
      pool->lastoffset = POOL_OVERHEAD + size;
      UNLOCK();

In other words, the lastoffset acts as an upper bound watermark.
I didn't want to do that optimization before, because it would have
resulted in a bigger pool header and waste of space. Now it's ok.

Cheers,
Vladimir



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4