Re: Missing free_var() at end of accum_sum_final()? - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Missing free_var() at end of accum_sum_final()?
Date
Msg-id 98d3ff28-3284-4ca7-9c4a-32ab84ab57f8@app.fastmail.com
Whole thread Raw
In response to Re: Missing free_var() at end of accum_sum_final()?  ("Joel Jacobson" <joel@compiler.org>)
Responses Re: Missing free_var() at end of accum_sum_final()?
List 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

pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: Missing free_var() at end of accum_sum_final()?
Next
From: Thomas Munro
Date:
Subject: Re: windows CI failing PMSignalState->PMChildFlags[slot] == PM_CHILD_ASSIGNED