Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0ea9279db601f2f8ede0166f07e22e7ecd5bcc5c
Ticket: 1299153fffffffffffffffffffffffffffffffff
MP_PREC is too large
User & Date: dgp on 2005-09-22 21:37:51
Changes

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    The libtommath library has a
    configuration value MP_PREC
    that specifies the minimum number
    of mp_digits in an mp_int.  The
    default value of MP_PREC is 64.
    
    This means that once an integer
    value is too large to fit in a Tcl_WideInt,
    the storage requirements balloon from
    8 bytes to hold 64 bits to 256 bytes
    just for the digits array holding 64 4-byte
    mp_digits to hold 65 bits.
    
    Even worse is the Tcl routine
    TclBNInitBignumFromLong()
    which calls mp_init_size().  Through
    some quirkiness in libtommath,
    mp_init_size actually creates an
    mp_int with a minimum of
    2*MP_PREC mp_digits.  So when
    we're explicitly creating an
    mp_int to hold a long value -- one we
    know will fit in two mp_digits -- we're
    forced to allocate 128 mp_digits, or
    a whopping 512 bytes, just for the
    digits array.
    
    These defaults may be appropriate
    for some clients of libtommath, but
    they're not a good fit for Tcl to require
    such an explosion of memory expense
    just to cross over into mp_int's.
    
    There is an MP_LOW_MEM configuration
    that sets MP_PREC to 8 rather than 64.
    That would help a lot, but even that seems
    too abrupt across the wide->bignum transition.
    A value of MP_PREC = 4 would seem to be
    a better fit for Tcl's bignum needs.
    
    Even with that revision, we should probably
    rewrite TclBNInitBignumFromLong to
    avoid making a call to mp_init_size().
    Other mp_init_size() callers ought to be
    examined as well.
    
    
    
  4. foundin changed to: "obsolete: 8.5a4"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dgp"
  9. subsystem changed to: "10. Objects"
  10. title changed to: "MP_PREC is too large"
  11. type changed to: "Bug"