Optimize memory allocation code

2020-09-25 Thread Li Japin
Hi, hackers! I find the palloc0() is similar to the palloc(), we can use palloc() inside palloc0() to allocate space, thereby I think we can reduce duplication of code. Best regards! -- Japin Li 0001-Optimize-memory-allocation-code.patch Description: 0001-Optimize-memory-allocation-code.pat

Re: Optimize memory allocation code

2020-09-25 Thread Julien Rouhaud
Hi, On Sat, Sep 26, 2020 at 12:14 AM Li Japin wrote: > > Hi, hackers! > > I find the palloc0() is similar to the palloc(), we can use palloc() inside > palloc0() > to allocate space, thereby I think we can reduce duplication of code. The code is duplicated on purpose. There's a comment at the

Re: Optimize memory allocation code

2020-09-25 Thread Li Japin
> On Sep 26, 2020, at 8:09 AM, Julien Rouhaud wrote: > > Hi, > > On Sat, Sep 26, 2020 at 12:14 AM Li Japin wrote: >> >> Hi, hackers! >> >> I find the palloc0() is similar to the palloc(), we can use palloc() inside >> palloc0() >> to allocate space, thereby I think we can reduce duplicati

Re: Optimize memory allocation code

2020-09-25 Thread Merlin Moncure
On Fri, Sep 25, 2020 at 7:32 PM Li Japin wrote: > > > > > On Sep 26, 2020, at 8:09 AM, Julien Rouhaud wrote: > > > > Hi, > > > > On Sat, Sep 26, 2020 at 12:14 AM Li Japin wrote: > >> > >> Hi, hackers! > >> > >> I find the palloc0() is similar to the palloc(), we can use palloc() > >> inside pal

Re: Optimize memory allocation code

2020-09-29 Thread Alvaro Herrera
On 2020-Sep-26, Li Japin wrote: > Thanks! How big is this overhead? Is there any way I can test it? You could also have a look at the assembly code that your compiler generates -- particularly examine how it changes. -- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Devel

Re: Optimize memory allocation code

2020-09-29 Thread Li Japin
On Sep 29, 2020, at 9:30 PM, Alvaro Herrera mailto:alvhe...@2ndquadrant.com>> wrote: On 2020-Sep-26, Li Japin wrote: Thanks! How big is this overhead? Is there any way I can test it? You could also have a look at the assembly code that your compiler generates -- particularly examine how it ch

Re: Optimize memory allocation code

2020-10-03 Thread Tomas Vondra
On Fri, Sep 25, 2020 at 07:37:07PM -0500, Merlin Moncure wrote: On Fri, Sep 25, 2020 at 7:32 PM Li Japin wrote: > On Sep 26, 2020, at 8:09 AM, Julien Rouhaud wrote: > > Hi, > > On Sat, Sep 26, 2020 at 12:14 AM Li Japin wrote: >> >> Hi, hackers! >> >> I find the palloc0() is similar to the