Re: Optimize numeric.c mul_var() using the Karatsuba algorithm - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Optimize numeric.c mul_var() using the Karatsuba algorithm
Date
Msg-id 2359967.1719762286@sss.pgh.pa.us
Whole thread Raw
In response to Re: Optimize numeric.c mul_var() using the Karatsuba algorithm  ("Joel Jacobson" <joel@compiler.org>)
Responses Re: Optimize numeric.c mul_var() using the Karatsuba algorithm
List pgsql-hackers
"Joel Jacobson" <joel@compiler.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Linux likely() unlikely() for PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: speed up a logical replica setup