public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: mliska <mliska@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 01/35] Introduce new type-based pool allocator.
Date: Wed, 27 May 2015 17:50:00 -0000	[thread overview]
Message-ID: <55660262.8050401@redhat.com> (raw)
In-Reply-To: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz>

On 05/27/2015 07:56 AM, mliska wrote:
> Hello.
>
> Following patch set attempts to replace old-style pool allocator
> to a type-based one. Moreover, as we utilize  classes and structs that are used
> just by a pool allocator, these types have overwritten ctors and dtors.
> Thus, using the allocator is much easier and we shouldn't cast types
> back and forth. Another beneficat can be achieved in future, as we will
> be able to call a class constructors to correctly register a location,
> where a memory is allocated (-fgather-detailed-mem-stats).
>
> Patch can boostrap on x86_64-linux-gnu and ppc64-linux-gnu and
> survives regression tests on x86_64-linux-gnu.
>
> Ready for trunk?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2015-04-30  Martin Liska  <mliska@suse.cz>
>
> 	* alloc-pool.c (struct alloc_pool_descriptor): Move definition
> 	to header file.
> 	* alloc-pool.h (pool_allocator::pool_allocator): New function.
> 	(pool_allocator::release): Likewise.
> 	(inline pool_allocator::release_if_empty): Likewise.
> 	(inline pool_allocator::~pool_allocator): Likewise.
> 	(pool_allocator::allocate): Likewise.
> 	(pool_allocator::remove): Likewise.
So on a general note, I don't like changing the size of the structure 
based on ENABLE_CHECKING.  If we've got other cases where we do this, 
then I guess it's OK, but if not, I'd prefer not to start doing so.


> ---

> +
> +  /* Align X to 8.  */
> +  size_t align_eight (size_t x)
> +  {
> +    return (((x+7) >> 3) << 3);
> +  }
> +
> +  const char *m_name;
> +#ifdef ENABLE_CHECKING
> +  ALLOC_POOL_ID_TYPE m_id;
> +#endif
> +  size_t m_elts_per_block;
> +
> +  /* These are the elements that have been allocated at least once and freed.  */
> +  allocation_pool_list *m_returned_free_list;
> +
> +  /* These are the elements that have not yet been allocated out of
> +     the last block obtained from XNEWVEC.  */
> +  char* m_virgin_free_list;
> +
> +  /* The number of elements in the virgin_free_list that can be
> +     allocated before needing another block.  */
> +  size_t m_virgin_elts_remaining;
> +  size_t m_elts_allocated;
> +  size_t m_elts_free;
> +  size_t m_blocks_allocated;
> +  allocation_pool_list *m_block_list;
> +  size_t m_block_size;
> +  size_t m_elt_size;
Several fields aren't documented.  They're largely self-explanatory, so 
I won't insist you document those trailing fields.  Your call whether or 
not to add docs for them.


> +
> +  /* Now align the size to a multiple of 4.  */
> +  size = align_eight (size);
Why not just aligned to 4, rather than a multiple of 4?  Presumably the 
extra 4 bytes don't matter in practice?

> +
> +template <typename T>
> +void
> +inline pool_allocator<T>::release_if_empty ()
> +{
> +  if (m_elts_free == m_elts_allocated)
> +    release ();
> +}
Is the release_if_empty all that useful in practice?

So the big issue in my mind continues to be the additional element in 
the structure when ENABLE_CHECKING is on.  As mentioned earlier, if 
we're already doing this elsewhere, then I won't object.  If we aren't, 
then I don't want to start doing so now.

The rest of the stuff are just minor questions, but nothing which would 
in my mind stop this from going forward.

Presumably your testing was with the whole series and they can't go in 
piecemeal, right?


jeff

  parent reply	other threads:[~2015-05-27 17:44 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 14:09 mliska
2015-05-27 14:00 ` [PATCH 03/35] Change use to type-based pool allocator in lra-lives.c mliska
2015-05-27 17:53   ` Jeff Law
2015-05-29 13:34     ` Martin Liška
2015-05-28  0:48   ` Trevor Saunders
2015-05-27 14:00 ` [PATCH 04/35] Change use to type-based pool allocator in lra.c mliska
2015-05-27 17:55   ` Jeff Law
2015-05-29 13:34     ` Martin Liška
2015-05-27 14:00 ` [PATCH 12/35] Change use to type-based pool allocator in cselib.c mliska
2015-05-29 13:38   ` Martin Liška
2015-05-27 14:00 ` [PATCH 10/35] Change use to type-based pool allocator in cfg.c mliska
2015-05-27 18:01   ` Jeff Law
2015-05-29 13:34     ` Martin Liška
2015-05-27 14:00 ` [PATCH 09/35] Change use to type-based pool allocator in c-format.c mliska
2015-05-27 14:16   ` Jakub Jelinek
2015-05-27 18:01   ` Jeff Law
2015-05-29 13:35     ` Martin Liška
2015-05-27 14:00 ` [PATCH 06/35] Change use to type-based pool allocator in ira-color.c mliska
2015-05-27 14:07 ` [PATCH 19/35] Change use to type-based pool allocator in sel-sched-ir.c mliska
2015-05-27 18:12   ` Jeff Law
2015-05-29 13:40     ` Martin Liška
2015-05-27 14:09 ` [PATCH 02/35] Change use to type-based pool allocator in et-forest.c mliska
2015-05-27 17:50   ` Jeff Law
2015-05-29 13:33     ` Martin Liška
2015-05-27 14:15 ` [PATCH 05/35] Change use to type-based pool allocator in ira-color.c mliska
2015-05-27 17:59   ` Jeff Law
2015-05-29 13:34     ` Martin Liška
2015-05-27 14:17 ` [PATCH 28/35] Change use to type-based pool allocator in ipa-profile.c mliska
2015-05-27 18:18   ` Jeff Law
2015-05-29 13:42     ` Martin Liška
2015-05-27 14:17 ` [PATCH 21/35] Change use to type-based pool allocator in regcprop.c mliska
2015-05-27 18:14   ` Jeff Law
2015-05-29 13:40     ` Martin Liška
2015-05-27 14:17 ` [PATCH 23/35] Change use to type-based pool allocator in tree-ssa-pre.c mliska
2015-05-27 18:59   ` Jeff Law
2015-05-29 13:41     ` Martin Liška
2015-05-27 14:17 ` [PATCH 34/35] Change use to type-based pool allocator in ira-build.c mliska
2015-05-27 14:17 ` [PATCH 35/35] Remove old pool allocator mliska
2015-05-27 19:40   ` Jeff Law
2015-05-29 14:11     ` Martin Liška
2015-05-27 14:17 ` [PATCH 32/35] Change use to type-based pool allocator in ira-build.c mliska
2015-05-27 19:34   ` Jeff Law
2015-05-29 13:44     ` Martin Liška
2015-05-27 14:18 ` [PATCH 27/35] Change use to type-based pool allocator in tree-ssa-structalias.c mliska
2015-05-27 18:20   ` Jeff Law
2015-05-29 13:42     ` Martin Liška
2015-05-27 14:19 ` [PATCH 14/35] Change use to type-based pool allocator in df-scan.c mliska
2015-05-29 13:38   ` Martin Liška
2015-05-27 14:19 ` [PATCH 11/35] Change use to type-based pool allocator in sh.c mliska
2015-05-27 18:03   ` Jeff Law
2015-05-29 13:37     ` Martin Liška
2015-05-27 14:19 ` [PATCH 08/35] Change use to type-based pool allocator in asan.c mliska
2015-05-27 18:01   ` Jeff Law
2015-05-27 14:19 ` [PATCH 25/35] Change use to type-based pool allocator in tree-ssa-sccvn.c mliska
2015-05-27 18:16   ` Jeff Law
2015-05-29 13:41     ` Martin Liška
2015-05-27 14:20 ` [PATCH 07/35] Change use to type-based pool allocator in var-tracking.c mliska
2015-05-29 13:34   ` Martin Liška
2015-05-27 14:20 ` [PATCH 29/35] Change use to type-based pool allocator in ipa-prop.c mliska
2015-05-27 18:22   ` Jeff Law
2015-05-29 13:42     ` Martin Liška
2015-05-27 14:20 ` [PATCH 31/35] Change use to type-based pool allocator in ipa-prop.c and ipa-cp.c mliska
2015-05-29 14:09   ` Martin Liška
2015-05-27 14:21 ` [PATCH 15/35] Change use to type-based pool allocator in dse.c mliska
2015-05-29 13:38   ` Martin Liška
2015-05-27 14:21 ` [PATCH 26/35] Change use to type-based pool allocator in tree-ssa-strlen.c mliska
2015-05-27 18:17   ` Jeff Law
2015-05-29 13:42   ` Martin Liška
2015-05-27 14:21 ` [PATCH 18/35] Change use to type-based pool allocator in stmt.c mliska
2015-05-27 18:13   ` Jeff Law
2015-05-29 13:39     ` Martin Liška
2015-05-27 14:21 ` [PATCH 20/35] Change use to type-based pool allocator in ira-build.c mliska
2015-05-27 18:15   ` Jeff Law
2015-05-29 13:39     ` Martin Liška
2015-05-27 14:21 ` [PATCH 30/35] Change use to type-based pool allocator in ipa-inline-analysis.c mliska
2015-05-29 14:06   ` Martin Liška
2015-05-27 14:21 ` [PATCH 24/35] Change use to type-based pool allocator in tree-ssa-reassoc.c mliska
2015-05-27 18:15   ` Jeff Law
2015-05-29 13:41     ` Martin Liška
2015-05-27 14:21 ` [PATCH 16/35] Change use to type-based pool allocator in tree-sra.c mliska
2015-05-27 18:11   ` Jeff Law
2015-05-29 13:39     ` Martin Liška
2015-05-27 14:42 ` [PATCH 22/35] Change use to type-based pool allocator in sched-deps.c mliska
2015-05-27 18:16   ` Jeff Law
2015-05-29 13:40     ` Martin Liška
2015-05-27 14:55 ` [PATCH 17/35] Change use to type-based pool allocator in tree-ssa-math-opts.c mliska
2015-05-27 18:12   ` Jeff Law
2015-05-29 13:39     ` Martin Liška
2015-05-27 14:58 ` [PATCH 33/35] Change use to type-based pool allocator in ira-color.c mliska
2015-05-27 18:24   ` Jeff Law
2015-05-28 11:23   ` Statically-allocated objects with non-trivial ctors (was Re: [PATCH 33/35] Change use to type-based pool allocator in ira-color.c.) David Malcolm
2015-05-28 17:38     ` Jeff Law
2015-05-28 18:30       ` Richard Biener
2015-05-28 18:34         ` Jakub Jelinek
2015-05-28 19:25           ` Martin Liška
2015-05-28 20:42             ` Trevor Saunders
2015-05-29  5:16     ` Trevor Saunders
2015-05-27 15:04 ` [PATCH 13/35] Change use to type-based pool allocator in df-problems.c mliska
2015-05-27 18:05   ` Jeff Law
2015-05-29 13:37     ` Martin Liška
2015-05-27 17:50 ` Jeff Law [this message]
2015-05-28 13:27   ` [PATCH 01/35] Introduce new type-based pool allocator Martin Liška
2015-05-28 18:04     ` Jeff Law
2015-05-29 13:33       ` Martin Liška
2015-05-30  5:14         ` Jeff Law
2015-06-02 10:10         ` Andreas Schwab
2015-06-02 13:57           ` Martin Liška
2015-06-02 14:00             ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55660262.8050401@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).