From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: MPS: bignums Date: Tue, 07 May 2024 14:17:17 +0200 Message-ID: References: <87bk5j12dc.fsf@gmail.com> <87jzk6ytzo.fsf_-_@gmail.com> <5E016D2B-A4A8-47A0-A679-7082E418C99C@gmail.com> <87bk5iyosj.fsf@gmail.com> <1EF104CF-ABF1-40CF-A6C6-E97C9998B685@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23158"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Helmut Eller , Emacs Devel , Eli Zaretskii To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 07 14:18:35 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s4JmF-0005oL-MK for ged-emacs-devel@m.gmane-mx.org; Tue, 07 May 2024 14:18:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4JlX-0003wR-M1; Tue, 07 May 2024 08:17:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4Jl7-0003jy-1Z for emacs-devel@gnu.org; Tue, 07 May 2024 08:17:28 -0400 Original-Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4Jl4-0001RB-VW; Tue, 07 May 2024 08:17:24 -0400 Original-Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a59b81d087aso645798166b.3; Tue, 07 May 2024 05:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715084240; x=1715689040; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hL5HU441Ziii67FSHeC1R9Imjq3fM2YwxQUXu93hDLg=; b=WcncoRyhLafy7BFG2LJy21U5bIb+xbnzCopEWhTJijk/gJHRzO9jZA5O+hgtN/GXRv /BHwAhaCoHeiR+4Hsko17hLMGtnU/BXMEkIpmoxbgPQaUXKHi5g4IS59uN1Zfv2042Tv /eTOXoV1NRP/5Ufvj6Oa2Rmc4RlGCM+0DuDn4/mzDl2MAZO4aZJWmFuS52Ixo47H+LCV hsyW2LYpPsj4BJwnkVbN49lFE6vffBDiHI2Oq08Kk9JU06rrqnObG+4aH1Gf8qTnnB9g fDV9ATDsbSfL0c+7OWO9ASYUcdYnKERg3/0k+ZHSF5GQAD4fGSJSWQlmIeKSqRbFWS2O Fuqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715084240; x=1715689040; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hL5HU441Ziii67FSHeC1R9Imjq3fM2YwxQUXu93hDLg=; b=nBbIn/Zb6nDDe7rRPpFIAsY90j27JnBVbbuJOjOLLWGLeZAvS48xYF1sh8DU/OUp60 /Y2T6EnfQwO0/+vKNxTto1mSvFfl300V2WD2zcIO1ODsKKb//25RaBZbzqeeeIzKEc49 akuVqyT3W6xVzuDygvgqrMenqdtslkKlgE/QNwYHq37MXVomjtK9cJBDEikyehajeo2B yRM/pw2vO8tebYC0vgwRQCfvrw8nXyEOK3cNJpGmOwJePcOnx8g8JN3oOeJPdjgZOU3i aRxHbPM6xIF+/ZRNvPr2dH/jm6k97FC4foM6TByQs1TRBifYoS3/+LZFzXkap+n7mvip OYiQ== X-Forwarded-Encrypted: i=1; AJvYcCUVwf1Qs87GjinEBqKHxIyxrtWgKvarYB75FKZsHY/QlwN9R8atARdiFKiirCpUaVqQ3NeEYu5wyxEVtzOXDyxQ8UjQV9NJW2e2/IFHDYO/sUU= X-Gm-Message-State: AOJu0YwWqNn06oyRAsdDDeBfriCXUK1mOXcD/YNc4+Ugq7kYP5JCZLx/ aX1S76jOeoKtlTD7J9463/XlbHNXcsweJDYXe9IBDCY8A79k6xhuZNnr6Q== X-Google-Smtp-Source: AGHT+IEHhzjDdHZ4G65tRQgqQlHRQu1vPVXKqXcEC/t78TRCBf57xzubmGtcy/x/35wbOCwPqFgAOg== X-Received: by 2002:a50:cd93:0:b0:568:9b13:77fe with SMTP id p19-20020a50cd93000000b005689b1377femr11901822edi.37.1715084239605; Tue, 07 May 2024 05:17:19 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36718.dip0.t-ipconnect.de. [217.227.103.24]) by smtp.gmail.com with ESMTPSA id u9-20020aa7d989000000b0057030326144sm6344790eds.47.2024.05.07.05.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 05:17:19 -0700 (PDT) In-Reply-To: <1EF104CF-ABF1-40CF-A6C6-E97C9998B685@gmail.com> ("Mattias =?utf-8?Q?Engdeg=C3=A5rd=22's?= message of "Tue, 7 May 2024 11:48:41 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=gerd.moellmann@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318936 Archived-At: Mattias Engdeg=C3=A5rd writes: > 7 maj 2024 kl. 11.06 skrev Helmut Eller : > >> 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 no= t worth it. > >> The reason why mpz_t in GMP is a mutable type is probably because they >> need computations of the kind a :=3D 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 bi= gnums, finalisation is accidental. For the uninitiated: This is not directly related to MPS. Bignums are the same as before with igc.