Message ID | 20230803142131.250087-1-andrzej.turko@gmail.com |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1184785vqx; Thu, 3 Aug 2023 07:24:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlExq7o1aTEQZVam7nWAA3YQEkj/ge7NPp12oMOwUexOTQMH0kQde3EPaEq8WCZcj6mR7ZLw X-Received: by 2002:a17:906:220c:b0:993:f2b4:13c9 with SMTP id s12-20020a170906220c00b00993f2b413c9mr7834319ejs.21.1691072681435; Thu, 03 Aug 2023 07:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691072681; cv=none; d=google.com; s=arc-20160816; b=ORbs0FVkvn6JeR1z39vogTPWJur1uOE89aWxgqVSjD0BuoKdF009511b9gE2s5EXjI 2npg8zGH4BSGm9IyMQNk40Aq/l7JWDd7DhahdBrfJujKQcUzmKwa08zcyAKP6jrfqebi N7j9d0pM9GUcVwDTg4/jZJ3Yfo0HxDIQICnDHWiLPfpmMVebhQR0ginxT/YVsnr0h96p lPQUUOnyWv1lWG3OdKGWYtpt47Kx2P8sc6O/8D9r3H+bv95NaeWMtYXhsQsIZXuE1W5R de2pu1RRsaGbz6wal4p8jaHGySQuuUyzfcxcGtwifw/zs/WfdMqfY1VxXStLgfCmlxgE 7rrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=zhAZWc2ODTeUsJF5pdsVYbOcpco8R7Xkvg+W6yrsDvU=; fh=k/nQU4IX+jAQueq710KA8dCAcoPPe4cl6LpGj9WeH7w=; b=CRfwk0k7DXxD1A+M9urr0UqqnAQFJQxROIKKkLNgfZIRMEhCxDsqEOnMBue32P8uDR u+HVZKKcIMnj9x/HbepqPVsuTXhGHdx839Gfa5VsoBKcI1wsva8OOoPKIfi62hlyn4GJ GQQZMuQybZIAR4X+NVFd01IvzZ0dDPvUyjt+sElVjCHaGmpNf3CIfeU7/itfGF6iX+Dr rBAJZSypEd2zLM0QppxBYsno4BXxO1mRhfa8d400SZ9HG9IJSIGsevsmJhxhsVW+DCT6 5Hxi9aA45fUIX2caqXoCtjomSLpVF7b6lKH4ylV43pQpq6wCYs/SBzGtdD1gDyg4yvI7 ypMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D9C2UdG0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id kk9-20020a170907766900b00992c92af6f5si643766ejc.869.2023.08.03.07.24.41 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D9C2UdG0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E918385843A for <ouuuleilei@gmail.com>; Thu, 3 Aug 2023 14:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E918385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691072628; bh=zhAZWc2ODTeUsJF5pdsVYbOcpco8R7Xkvg+W6yrsDvU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=D9C2UdG0LIbZZLu7uEOYURvny4+a1eskvoGRN6ALkwYQO0pMhEbKRv5reWhHmClvX gvbPli9YwPO42tCc+iBU9VstmTXAw72vz7PBVIg/gCPRqlh6xM+b/vfInplr5IJO7O GKrfDaFRNNqY23mQFeKzk1CSQgNv61b8y7uaJkyI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 331CE3858D1E for <gcc-patches@gcc.gnu.org>; Thu, 3 Aug 2023 14:23:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 331CE3858D1E Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b9c0391749so16597221fa.0 for <gcc-patches@gcc.gnu.org>; Thu, 03 Aug 2023 07:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691072581; x=1691677381; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zhAZWc2ODTeUsJF5pdsVYbOcpco8R7Xkvg+W6yrsDvU=; b=T/y4/9FUz0qX+1Tj4kXzM/XVgLCwWYfnxInm2+swKt5c9O/2NNPX4otn0hDcUakSy9 tvIG4s/S1unMwmvb5BRb+NKsbxs6D9+qCaPvB4QoUOhxtcItiDLkR2C9IAV1S9JsP2vC u+iLqLj0VokrY0UF7dAZBX7D6g6Nl0uushyUWUVZTPwrHUXBz1OTY8WFwN5J6h9miX+q 0D4m3CSJEi31bsXrLc01aa6pLELTwcfnxsHc85fvPmN896WQ6fpfCZDdVjM2J+e3BZGX IFB39WbzRyAElBtVVDT/l0wTKrd+ZLNEUkitO8ZpX6PIpD4zsXh4GVYjtDk412qgIuua lFRA== X-Gm-Message-State: ABy/qLa1erU164Dv8ESadkBqVjGnlVeorDwaM90Q1PT64J25pv4OO2qN u/9qicFk+SdgV/WcRBvXnF8pWqTuXobXilMY X-Received: by 2002:a2e:8ec3:0:b0:2b9:ec57:c330 with SMTP id e3-20020a2e8ec3000000b002b9ec57c330mr7670488ljl.7.1691072581158; Thu, 03 Aug 2023 07:23:01 -0700 (PDT) Received: from amwld-aturko1.us.drwholdings.com ([149.14.21.6]) by smtp.gmail.com with ESMTPSA id f9-20020a7bc8c9000000b003fba92fad35sm4371349wml.26.2023.08.03.07.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:23:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Andrzej Turko <andrzej.turko@gmail.com> Subject: [PATCH 0/3 v3] genmatch: Speed up recompilation after changes to match.pd Date: Thu, 3 Aug 2023 16:21:28 +0200 Message-Id: <20230803142131.250087-1-andrzej.turko@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Andrzej Turko via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Andrzej Turko <andrzej.turko@gmail.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773218227840290182 X-GMAIL-MSGID: 1773218227840290182 |
Series |
genmatch: Speed up recompilation after changes to match.pd
|
|
Message
Andrzej Turko
Aug. 3, 2023, 2:21 p.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. As for Richard Biener's remarks on executable size (cc1plus): 1. The first version of the change decreased (sic!) the executable size by approximately 120 kB (.text and .data sections grew by correspondingly 14 and 2 kB, but .debug_info section shrank by roughly 170 kB). 2. In the current version (V3) the binary size increases by 36 kB (.text grows by 3 kB and .rodata by 14 kB, the rest of the increase can be mostly attributed to debug sections). One can choose between those variants just by taking the third commit either from this or the first version of the patch series. Possible optimization: Currently, the lookup table for line numbers contains duplicate values. If I remove them, the table would shrink by 40-50% reducing the increase in .data sections. Is it worth pursuing? And if so, would it be better if I integrate this into this patch series or implement it separately? Also, can I assume that genmatch is producing source code using a single input file per invocation? Currently, this is the case. 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 | 92 +++++++++++++++++++++++++++++------ gcc/ordered-hash-map-tests.cc | 19 ++++++-- gcc/ordered-hash-map.h | 26 ++++++++++ 4 files changed, 119 insertions(+), 22 deletions(-)