Message ID | 20221219164558.378363-1-tromey@adacore.com |
---|---|
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DBAA3858439 for <patchwork@sourceware.org>; Mon, 19 Dec 2022 16:46:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DBAA3858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671468395; bh=RCTeA+j4gnlVTiJEXooBYHLutYjr51r1USXi7p2vhiI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c75HQ+VP5mq2Nm7R9BDeIYeadetr00mRzdI30WcYJ0IedSKqqfyejo5Ie3kC1EoXD S7ptpAkwF1K+bPq3/JbTUkmpN/DdK+0wkyGP0g+Krc63u5VDHZGA3MEb0K99WcOFbl J7AkaXGxAdnbXVDr85xBJR7rKVXvljc6AUMD1kr8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id CBB5F3858D1E for <gdb-patches@sourceware.org>; Mon, 19 Dec 2022 16:46:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBB5F3858D1E Received: by mail-io1-xd32.google.com with SMTP id z144so4977382iof.3 for <gdb-patches@sourceware.org>; Mon, 19 Dec 2022 08:46:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RCTeA+j4gnlVTiJEXooBYHLutYjr51r1USXi7p2vhiI=; b=4Ca12kKPpP6z77wQQb87/08UUK3+pCYTcxSkN0mEEpPZmyciMhS63Qn31A3EJyuFrY Qbe92+0AhM7XuGYf6wE6x5T1+jJFZu/8/aS9nuwF2SoAR5feO6qXPssih4MSd4vHegbu DzW5OSjU8WjZczBmaoFUaQUuAObGzrO+yCGWuBjbrApT+qe4sNcW1nHXIqT+o4c2jJs7 I8BqN5EdF7OpCgpRLLlVu35caSySsnoSwyPEremHdVRsGLBuaURD31k/iRGYj7w7oY/b i3e2QBszGSeouDiSt02/GBOJYuMy1DOfUJm9G6TQr+fUHtc2J/T9yfb47mTfQJ5nnJJy JU1w== X-Gm-Message-State: ANoB5plWYw8MM0TtmhHUx1C8zmtkdZsUCRkTHAJIhShO77TZKKwxccNL o6Tah6W25VA4AEyYE+XQYx03BVrImYSV/Q9c X-Google-Smtp-Source: AA0mqf77jaaHuh+xsNnBAe0Zk+KK8Cu3ja5owhkzn2q+bX0B+61iEcqXhayeGIKiEILF6X0pfrvlWA== X-Received: by 2002:a5d:9284:0:b0:6df:3b35:4a2d with SMTP id s4-20020a5d9284000000b006df3b354a2dmr21618423iom.16.1671468366963; Mon, 19 Dec 2022 08:46:06 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id x22-20020a056638027600b00363fe31cf55sm3645787jaq.40.2022.12.19.08.46.06 for <gdb-patches@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 08:46:06 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH v3 0/2] Write DWARF index cache files in background Date: Mon, 19 Dec 2022 09:45:56 -0700 Message-Id: <20221219164558.378363-1-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tom Tromey <tromey@adacore.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Write DWARF index cache files in background
|
|
Message
Tom Tromey
Dec. 19, 2022, 4:45 p.m. UTC
Here's v3 of the patches to write the DWARF index in the background. v2 was here: https://sourceware.org/pipermail/gdb-patches/2022-June/189889.html This hides a user-noticeable pause when the feature is enabled. (Note that, when the feature is used in batch mode, the pause is still seen.) This version of the series fixes a possible race that I found in v2. Essentially, the index-writing background job must be started after all the finalization tasks have started. There's a comment in the code explaining this. Let me know what you think. Tom
Comments
>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Here's v3 of the patches to write the DWARF index in the background.
Tom> v2 was here:
Tom> https://sourceware.org/pipermail/gdb-patches/2022-June/189889.html
Tom> This hides a user-noticeable pause when the feature is enabled. (Note
Tom> that, when the feature is used in batch mode, the pause is still
Tom> seen.)
Tom> This version of the series fixes a possible race that I found in v2.
Tom> Essentially, the index-writing background job must be started after
Tom> all the finalization tasks have started. There's a comment in the
Tom> code explaining this.
I'm checking this in now.
Tom
On 2/24/23 13:46, Tom Tromey via Gdb-patches wrote: >>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes: > > Tom> Here's v3 of the patches to write the DWARF index in the background. > Tom> v2 was here: > > Tom> https://sourceware.org/pipermail/gdb-patches/2022-June/189889.html > > Tom> This hides a user-noticeable pause when the feature is enabled. (Note > Tom> that, when the feature is used in batch mode, the pause is still > Tom> seen.) > > Tom> This version of the series fixes a possible race that I found in v2. > Tom> Essentially, the index-writing background job must be started after > Tom> all the finalization tasks have started. There's a comment in the > Tom> code explaining this. > > I'm checking this in now. > > Tom I started seeing this, I guess it's related: FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there Simon
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> I started seeing this, I guess it's related:
Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there
Yeah, I will look into it soon.
Tom
Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there I can't reliably reproduce this. However, I believe the problem is that because the cache file is written in the background, the test is racy. I think the appended should fix it. This just mirrors something done in test_cache_enabled_hit, and the idea is that waiting for gdb to exit ensures that the cache file will have been written. Tom diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp index 0614d4ee2db..d9a6145b5df 100644 --- a/gdb/testsuite/gdb.base/index-cache.exp +++ b/gdb/testsuite/gdb.base/index-cache.exp @@ -157,6 +157,9 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } { lassign [ls_host $cache_dir] ret files_before + # Just to populate the cache. + run_test_with_flags $cache_dir on {} + run_test_with_flags $cache_dir on { lassign [ls_host $cache_dir] ret files_after
On 3/3/23 11:41, Tom Tromey wrote: > Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created > Simon> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there > > I can't reliably reproduce this. > > However, I believe the problem is that because the cache file is written > in the background, the test is racy. Ok, thanks for the tip. It should be possible to reliably reproduce it with that change then, which makes GDB take more time to write the index: diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 62c2cc6ac7de..d3bad4aaa0c9 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1485,6 +1485,7 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir, (dwz_index_wip.has_value () ? dwz_index_wip->out_file.get () : NULL)); + sleep(3); objfile_index_wip.finalize (); if (dwz_index_wip.has_value ()) > I think the appended should fix it. This just mirrors something done in > test_cache_enabled_hit, and the idea is that waiting for gdb to exit > ensures that the cache file will have been written. > > Tom > > diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp > index 0614d4ee2db..d9a6145b5df 100644 > --- a/gdb/testsuite/gdb.base/index-cache.exp > +++ b/gdb/testsuite/gdb.base/index-cache.exp > @@ -157,6 +157,9 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } { > > lassign [ls_host $cache_dir] ret files_before > > + # Just to populate the cache. > + run_test_with_flags $cache_dir on {} > + > run_test_with_flags $cache_dir on { > > lassign [ls_host $cache_dir] ret files_after I don't understand this. The first run_test_with_flags will populate the cache, so the second run will use the cache and be a cache hit. The tests that checks that the expected file is there will work. But the check_cache_stats test will operate the GDB that will have had a cache hit, so we won't get the expected result (a cache miss). I think this could be solved with a maintenance command to explicitly wait for index cache creation (calls wait_for_index_cache). I don't see another reliable way. What do you think? I can implement it if you think it would work. Simon
Simon> I don't understand this. Yeah, sorry, I didn't properly understand the test. Simon> I think this could be solved with a maintenance command to explicitly Simon> wait for index cache creation (calls wait_for_index_cache). I don't see Simon> another reliable way. What do you think? I can implement it if you Simon> think it would work. I think you're right. I can handle it. Tom
On 3/3/23 12:29, Tom Tromey via Gdb-patches wrote: > Simon> I don't understand this. > > Yeah, sorry, I didn't properly understand the test. > > Simon> I think this could be solved with a maintenance command to explicitly > Simon> wait for index cache creation (calls wait_for_index_cache). I don't see > Simon> another reliable way. What do you think? I can implement it if you > Simon> think it would work. > > I think you're right. I can handle it. I spotted another failure, when running with native-extended-gdbserver: 254 (gdb) file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache^M 255 Reading symbols from /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache...^M 256 /home/smarchi/src/binutils-gdb/gdb/gdbtypes.h:967: internal-error: field: Assertion `idx >= 0 && idx < num_fields ()' failed.^M 257 A problem internal to GDB has been detected,^M 258 further debugging may prove unreliable.^M 259 ERROR: Couldn't load index-cache into GDB (GDB internal error). I don't know why it would be specific to native-extended-gdbserver, maybe it changes the timing in just the right (wrong) way. I haven't dug into it yet. Simon