1. 30 Mar, 2002 4 kayıt (commit)
    • Tim Peters's avatar
    • Tim Peters's avatar
      Now that we're no longer linking arenas together, there's no need to · 3c83df20
      Tim Peters yazdı
      waste the first pool if malloc happens to return a pool-aligned address.
      
      This means the number of pools per arena can now vary by 1.  Unfortunately,
      the code counted up from 0 to a presumed constant number of pools.  So
      changed the increasing "watermark" counter to a decreasing "nfreepools"
      counter instead, and fiddled various stuff accordingly.  This also allowed
      getting rid of two more macros.
      
      Also changed the code to align the first address to a pool boundary
      instead of a page boundary.  These are two parallel sets of macro #defines
      that happen to be identical now, but the page macros are in theory more
      restrictive (bigger), and there's simply no reason I can see that it
      wasn't aligning to the less restrictive pool size all along (the code
      only relies on pool alignment).
      
      Hmm.  The "page size" macros aren't used for anything *except* defining
      the pool size macros, and the comments claim the latter isn't necessary.
      So this has the feel of a layer of indirection that doesn't serve a
      purpose; should probably get rid of the page macros now.
      3c83df20
    • Tim Peters's avatar
      Retract the claim that this is always safe if PyMem_{Del, DEL, Free, FREE} · 12300686
      Tim Peters yazdı
      are called without the GIL.  It's incredibly unlikely to fail, but I can't
      make this bulletproof without either adding a lock for exclusion, or
      giving up on growing the arena base-address vector (it would be safe if
      this were a static array).
      12300686
    • Tim Peters's avatar
      Lots of changes: · d97a1c00
      Tim Peters yazdı
      + A new scheme for determining whether an address belongs to a pymalloc
        arena.  This should be 100% reliable.  The poolp->pooladdr and
        poolp->magic members are gone.  A new poolp->arenaindex member takes
        their place.  Note that the pool header overhead doesn't actually
        shrink, though, since the header is padded to a multiple of 8 bytes.
      
      + _PyMalloc_Free and _PyMalloc_Realloc should now be safe to call for
        any legit address, whether obtained from a _PyMalloc function or from
        the system malloc/realloc.  It should even be safe to call
         _PyMalloc_Free when *not* holding the GIL, provided that the passed-in
        address was obtained from system malloc/realloc.  Since this is
        accomplished without any locks, you better believe the code is subtle.
        I hope it's sufficiently commented.
      
      + The above implies we don't need the new PyMalloc_{New, NewVar, Del}
        API anymore, and could switch back to PyObject_XXX without breaking
        existing code mixing PyObject_XXX with PyMem_{Del, DEL, Free, FREE}.
        Nothing is done here about that yet, and I'd like to see this new
        code exercised more first.
      
      + The small object threshhold is boosted to 256 (the max).  We should
        play with that some more, but the old 64 was way too small for 2.3.
      
      + Getting a new arena is now done via new function new_arena().
      
      + Removed some unused macros, and squashed out some macros that were
        used only once to define other macros.
      
      + Arenas are no longer linked together.  A new vector of arena base
        addresses had to be created anyway to make address classification
        bulletproof.
      
      + A lot of the patch size is an illusion:  given the way address
        classification works now, it was more convenient to switch the
        sense of the prime "if" tests in the realloc and free functions,
        so the "if" and "else" blocks got swapped.
      
      + Assorted minor code, comment and whitespace cleanup.
      
      Back to the Windows installer <wink>.
      d97a1c00
  2. 29 Mar, 2002 33 kayıt (commit)
  3. 28 Mar, 2002 3 kayıt (commit)