[0/3,v4] genmatch: Speed up recompilation after changes to match.pd

Message ID 20230807095901.267099-1-andrzej.turko@gmail.com
Headers
Series genmatch: Speed up recompilation after changes to match.pd |

Message

Andrzej Turko Aug. 7, 2023, 9:58 a.m. UTC
  The following reduces the number of object files that need to be rebuilt
after match.pd has been modified. Right now a change to match.pd which
adds/removes a line almost always forces recompilation of all files that
genmatch generates from it. This is because of unnecessary changes to
the generated .cc files:

1. Function names and ordering change as does the way the functions are
        distributed across multiple source files.
2. Code locations from match.pd are quoted directly (including line
        numbers) by logging fprintf calls.

This patch addresses the those issues without changing the behaviour
of the generated code. The first one is solved by making sure that minor
changes to match.pd do not influence the order in which functions are
generated. The second one by using a lookup table with line numbers.

Now a change to a single function will trigger a rebuild of 4 object
files (one with the function  and the one with the lookup table both for
gimple and generic) instead all of them (20 by default).
For reference, this decreased the rebuild time with 48 threads from 3.5
minutes to 1.5 minutes on my machine.

V2:
        * Placed the change in Makefile.in in the correct commit.
        * Used a separate logging function to reduce size of the
        executable.

V3:
	* Fix a bug from 'genmatch: Log line numbers indirectly',
	which was introduced in V2.

V4:
	* Remove duplicate line numbers in the lookup table.
	* Do not define dump_log functions if they are not called.
       

Note for reviewers: I do not have write access.

Andrzej Turko (3):
  Support get_or_insert in ordered_hash_map
  genmatch: Reduce variability of generated code
  genmatch: Log line numbers indirectly

 gcc/Makefile.in               |  4 +-
 gcc/genmatch.cc               | 98 +++++++++++++++++++++++++++++------
 gcc/ordered-hash-map-tests.cc | 19 +++++--
 gcc/ordered-hash-map.h        | 26 ++++++++++
 4 files changed, 125 insertions(+), 22 deletions(-)
  

Comments

Richard Biener Aug. 8, 2023, 12:58 p.m. UTC | #1
On Mon, Aug 7, 2023 at 12:04 PM Andrzej Turko <andrzej.turko@gmail.com> wrote:
>
> The following reduces the number of object files that need to be rebuilt
> after match.pd has been modified. Right now a change to match.pd which
> adds/removes a line almost always forces recompilation of all files that
> genmatch generates from it. This is because of unnecessary changes to
> the generated .cc files:
>
> 1. Function names and ordering change as does the way the functions are
>         distributed across multiple source files.
> 2. Code locations from match.pd are quoted directly (including line
>         numbers) by logging fprintf calls.
>
> This patch addresses the those issues without changing the behaviour
> of the generated code. The first one is solved by making sure that minor
> changes to match.pd do not influence the order in which functions are
> generated. The second one by using a lookup table with line numbers.
>
> Now a change to a single function will trigger a rebuild of 4 object
> files (one with the function  and the one with the lookup table both for
> gimple and generic) instead all of them (20 by default).
> For reference, this decreased the rebuild time with 48 threads from 3.5
> minutes to 1.5 minutes on my machine.
>
> V2:
>         * Placed the change in Makefile.in in the correct commit.
>         * Used a separate logging function to reduce size of the
>         executable.
>
> V3:
>         * Fix a bug from 'genmatch: Log line numbers indirectly',
>         which was introduced in V2.
>
> V4:
>         * Remove duplicate line numbers in the lookup table.
>         * Do not define dump_log functions if they are not called.

Thanks - I'll push this version after double-checking bootstrap.

Richard.

>
> Note for reviewers: I do not have write access.
>
> Andrzej Turko (3):
>   Support get_or_insert in ordered_hash_map
>   genmatch: Reduce variability of generated code
>   genmatch: Log line numbers indirectly
>
>  gcc/Makefile.in               |  4 +-
>  gcc/genmatch.cc               | 98 +++++++++++++++++++++++++++++------
>  gcc/ordered-hash-map-tests.cc | 19 +++++--
>  gcc/ordered-hash-map.h        | 26 ++++++++++
>  4 files changed, 125 insertions(+), 22 deletions(-)
>
> --
> 2.34.1
>