Re: Missing free_var() at end of accum_sum_final()?

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Missing free_var() at end of accum_sum_final()?
Date: 2023-02-19 22:55:38
Message-ID: 98d3ff28-3284-4ca7-9c4a-32ab84ab57f8@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Feb 19, 2023, at 23:16, Joel Jacobson wrote:
> Hi again,
>
> Ignore previous patch, new correct version attached, that also keeps
> track of if the buf-field is in use or not.

Ops! One more thinko, detected when trying fixed_buf[8], which caused a seg fault.

To fix, a init_var() in alloc_var() is needed when we will use the fixed_buf instead of allocating,
since alloc_var() could be called in a loop for existing values, like in sqrt_var() for instance.

Attached new version produces similar benchmark results, even with the extra init_var():

HEAD:

format | pretty_time | count
-----------------------+-------------+-------
numeric_in(1234,0,-1) | 31 ns | 74
numeric_in(1234,0,-1) | 32 ns | 26
(2 rows)

0003-fixed-buf.patch:

format | pretty_time | count
-----------------------+-------------+-------
numeric_in(1234,0,-1) | 24 ns | 1
numeric_in(1234,0,-1) | 25 ns | 84
numeric_in(1234,0,-1) | 26 ns | 15
(3 rows)

/Joel

Attachment Content-Type Size
0003-fixed-buf.patch application/octet-stream 3.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-02-19 23:28:54 Re: windows CI failing PMSignalState->PMChildFlags[slot] == PM_CHILD_ASSIGNED
Previous Message Joel Jacobson 2023-02-19 22:16:43 Re: Missing free_var() at end of accum_sum_final()?