Re: Optimize numeric.c mul_var() using the Karatsuba algorithm

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joel Jacobson" <joel(at)compiler(dot)org>
Cc: "Dean Rasheed" <dean(dot)a(dot)rasheed(at)gmail(dot)com>, "Michael Paquier" <michael(at)paquier(dot)xyz>, "Aaron Altman" <aaronaltman(at)posteo(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Optimize numeric.c mul_var() using the Karatsuba algorithm
Date: 2024-06-30 15:44:46
Message-ID: 2359967.1719762286@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Joel Jacobson" <joel(at)compiler(dot)org> writes:
> On Sat, Jun 29, 2024, at 17:25, Tom Lane wrote:
>> (In general I find this patch seriously undercommented.)

> However, I think the comments above split_var_at(),
> mul_var_karatsuba_full() and mul_var_karatsuba_half()
> are quite good already, what do you think?

Not remarkably so. For starters, heaven help the reader who has
no idea what "the Karatsuba algorithm" refers to. Nor is there
any mention of why (or when) it's better than the traditional
algorithm. You could at least do people the courtesy of providing
a link to the wikipedia article that you're assuming they've
memorized.

There's also a discussion to be had about why Karatsuba is
a better choice than other divide-and-conquer multiplication
methods. Why not Toom-Cook, for example, which the aforesaid
wikipedia page says is faster yet? I suppose you concluded
that the extra complexity is unwarranted, but this is the
sort of thing I'd expect to see explained in the comments.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-06-30 16:59:54 Re: speed up a logical replica setup
Previous Message Tom Lane 2024-06-30 15:23:52 Re: Linux likely() unlikely() for PostgreSQL