From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: Helmut Eller <eller.helmut@gmail.com>,
Emacs Devel <emacs-devel@gnu.org>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: MPS: bignums
Date: Tue, 07 May 2024 14:17:17 +0200 [thread overview]
Message-ID: <m2cypxerzm.fsf@pro2.fritz.box> (raw)
In-Reply-To: <1EF104CF-ABF1-40CF-A6C6-E97C9998B685@gmail.com> ("Mattias Engdegård"'s message of "Tue, 7 May 2024 11:48:41 +0200")
Mattias Engdegård <mattias.engdegard@gmail.com> writes:
> 7 maj 2024 kl. 11.06 skrev Helmut Eller <eller.helmut@gmail.com>:
>
>> It's not so easy. A mpz_t is a resizable vector of "limbs". The memory
>> for the mpz_t struct are managed by MPS but the memory for the limbs
>> isn't. The function mp_set_memory_functions could perhaps be used to
>> allocate limbs in an MPS managed pool; but these functions include a
>> realloc variant which is not directly supported by MPS. We would also
>> have to trace the reference to the limbs.
>
> We could use the mpn interface directly but it's less convenient and mpz takes care of boring work, as well as some useful logic so it's probably not worth it.
>
>> The reason why mpz_t in GMP is a mutable type is probably because they
>> need computations of the kind a := a + b a lot when doing crypto stuff
>> and in this case memory can be reused efficiently.
>
> Yes, but our bignums aren't mutable. I think it would probably end up
> cheaper to use scratch mpz for the computation, create a single MPS
> allocation for the bignum, and memcpy the data to it. (Especially
> since bignums are small.)
>
>> I think we need to get finalization not just for bignums but also for
>> hash tables.
>
> Yes, but that's actually necessary: they are mutable and can grow. For bignums, finalisation is accidental.
For the uninitiated: This is not directly related to MPS. Bignums are
the same as before with igc.
next prev parent reply other threads:[~2024-05-07 12:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-05 6:16 MPS: optimized build Gerd Möllmann
2024-05-05 7:50 ` Andrea Corallo
2024-05-05 8:05 ` Gerd Möllmann
2024-05-05 8:16 ` Andrea Corallo
2024-05-06 13:44 ` Helmut Eller
2024-05-06 20:28 ` Andrea Corallo
2024-05-07 7:13 ` MPS: bignums (was: MPS: optimized build) Helmut Eller
2024-05-07 7:21 ` MPS: bignums Gerd Möllmann
2024-05-07 8:15 ` MPS: bignums (was: MPS: optimized build) Mattias Engdegård
2024-05-07 9:06 ` MPS: bignums Helmut Eller
2024-05-07 9:27 ` Gerd Möllmann
2024-05-07 9:48 ` Mattias Engdegård
2024-05-07 12:17 ` Gerd Möllmann [this message]
2024-05-07 16:33 ` Helmut Eller
2024-05-07 16:38 ` Mattias Engdegård
2024-05-08 12:59 ` Helmut Eller
2024-05-08 13:08 ` Gerd Möllmann
2024-05-08 13:13 ` Helmut Eller
2024-05-08 13:14 ` Gerd Möllmann
2024-05-05 20:20 ` MPS: optimized build Dmitry Gutov
2024-05-06 7:03 ` Gerd Möllmann
2024-05-06 11:49 ` Eli Zaretskii
2024-05-06 15:16 ` Dmitry Gutov
2024-05-06 15:17 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2cypxerzm.fsf@pro2.fritz.box \
--to=gerd.moellmann@gmail.com \
--cc=eliz@gnu.org \
--cc=eller.helmut@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=mattias.engdegard@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.