Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tcf-dev] Speedup compute_reverse_lookup_indices.
  • From: Eugene Tarassov <eugene.tarassov@xxxxxxx>
  • Date: Thu, 26 May 2022 03:30:47 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 20.83.241.18) smtp.rcpttodomain=eclipse.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=fail (48)
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=xilinx.com; dmarc=pass action=none header.from=xilinx.com; dkim=pass header.d=xilinx.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H08+TwVDnY/RxF1N5gVkpp0ezrbiWtJWT+PBjlMz21A=; b=avtgFi+eti7AfQFhH0rsBq3BMgxcjSIFjz/A7p8l8bbZIlalkg9ISB+M104HT1l39SPrmAStLKXBEwht+E1rn6lo/pcknYI1KnRtkneV5O98E02gDfTX7urn7pbeSCmankT6mb2ctq1DEgmhO82r+2q+ZaVLf+DEuxoPdUxAFbzb98C/EB7aJ2x3ky+gE3TV8PDVhHnbJg9x3D6tkYGV5wRLdopv3Zqo2qdDHy2yzKfeE9T8bH/qgj0+ck+9Yfiav1XqbJBcBLK1QwHE2rnW8nOFhdCOm/cRo7umYVMop82lkL6NcsxEhjsUQhSodHXLhPc/d0oufMj4tkj6ug9yEw==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H08+TwVDnY/RxF1N5gVkpp0ezrbiWtJWT+PBjlMz21A=; b=g1Vv4XqB4u2SaZJQHDpN3SqXagJ6Ga2uW4hU3JODBmvrBh66cyYV0WWrl5MUTn6smDCkf9rwyZBHzu7+eXGccIyvt4b0ihioLwfXdwJBCD2fEu/UnE0aArFp9DlvxhuQ7BpL7G/IZ7zKb2tQQTAMrDQ241F6EYE702hEtGvv+anHsVpdc264Vj+vQRZ1w+doZNBRjOQjIfSnsRDuvoD/mfv4ZbANKKguqdXdRNVkvv+LxDIbni+fyCjDE8t5Q9gikZTTFewStcQj8PrB28UT6ObRiIxuem/hmdJ0YqI1FPrQSQZThLz5zXz+AeNGAUESYWpQyS03I4YtiMYsrwKJnA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=fail; b=CtM15Do0W6yU88SeUe9UuKukELykQ+uTlqe3zX6UgMLsXlOM92hiq2vR5x0cVCl4kP0n3rLUzThPhpBO/ps7t/pk7WUT9fmJWK3XQMRK43+Itq9yiTdQN2ucdqwkmbvmaRn9oMSFbKSZDDt7rW3cm46rHTRzYZKNuk4EMrB0z9kxWvbsHa5yus6gvWrokYDpwifDgyHsbutQ52FAv6quiBQ2zlLqJ70BaJkxXzp3d7UgfiVrScw/cgzO+++cbBShSe6vK+o515RRi8G1cymBcxL7gvs6EvQyGa1M8bjQgkHnXL8AGvngVIq75R5/oOjopSwa57nVic5St1GpZs5hyA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bq8oSo1SaE9CImZG8huoTVwpC+4B2Z60AwdgqRJIWJ2rD2VDmH6cXapVA+wWatnqUW91m2iPO3WWrRt0w7TfzeK1LSeftsYqCixarkLcddDlCYZZNcjokPdMadyLOsDoCADU79943IMx4hxS2tH5+I34mBp2lKNIyLCprhvCdeuSSxlubKJB4IoD9suGKHgx5YcqNiqwzD4hsBO1A2UIwZ2FAIJ6zKJ5Tg4xQIcpIhJ9kt/7J/gIKcNZ7byQAZcLlzbkB8Eu7Iyn/kPj0Sqk8Ueqs5x5LVjJU4T2YT05mbUzu581d3js3vS1O6mT9ud5wFTMViWTRsFw3WVODDO4vQ==
  • Delivered-to: tcf-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/tcf-dev/>
  • List-help: <mailto:tcf-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/tcf-dev>, <mailto:tcf-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/tcf-dev>, <mailto:tcf-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHYcA+7z7wZQoMSbUiTqIpkk0d8Nq0wgdEg
  • Thread-topic: [tcf-dev] Speedup compute_reverse_lookup_indices.

Hi Rafal,

Could you, please, create a bug report at https://bugs.eclipse.org/bugs/ and complete Eclipse Contributor Agreement https://accounts.eclipse.org/user/eca ?

I cannot accept code over email or forums because of potential copyright problems.

Thanks,
Eugene

-----Original Message-----
From: tcf-dev <tcf-dev-bounces@xxxxxxxxxxx> On Behalf Of Rafal Hibner
Sent: Wednesday, May 25, 2022 1:16 AM
To: tcf-dev@xxxxxxxxxxx
Subject: [tcf-dev] Speedup compute_reverse_lookup_indices.

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.


Hello everyone. This is my first contributiuon here.

Inefficient implementation of mStatesIndex creation results in long startup of debug context. This patch changes O(N^2) complexity to O(N).
It vastly speeds up startup with big symbol files (>300MB).

---
 agent/tcf/services/dwarfcache.c | 33
++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c index f073a08..8b2942a 100644
--- a/agent/tcf/services/dwarfcache.c
+++ b/agent/tcf/services/dwarfcache.c
@@ -2373,22 +2373,25 @@ static int state_text_pos_comparator(const void
* x1, const void * x2) {
 }

 static void compute_reverse_lookup_indices(DWARFCache * Cache, CompUnit * Unit) {
-    U4_T i;
+    U4_T i,j;
     qsort(Unit->mStates, Unit->mStatesCnt, sizeof(LineNumbersState), state_address_comparator);
-    Unit->mStatesIndex = (LineNumbersState
**)loc_alloc(sizeof(LineNumbersState *) * Unit->mStatesCnt);
-    for (i = 0; i < Unit->mStatesCnt; i++) {
-        LineNumbersState * s1 = Unit->mStates + i;
-        while (i + 1 < Unit->mStatesCnt) {
-            LineNumbersState * s2 = s1 + 1;
-            if (s1->mFile != s2->mFile ||
-                s1->mLine != s2->mLine || s1->mColumn != s2->mColumn
||
-                s1->mFlags != s2->mFlags || s1->mISA != s2->mISA ||
-                s1->mOpIndex != s2->mOpIndex || s1->mDiscriminator !=
s2->mDiscriminator) break;
-            memmove(s2, s2 + 1, sizeof(LineNumbersState) *
(Unit->mStatesCnt - i - 2));
-            Unit->mStatesCnt--;
-        }
-        Unit->mStatesIndex[i] = s1;
-    }
+    Unit->mStatesIndex =
(LineNumbersState**)loc_alloc(sizeof(LineNumbersState*) *
Unit->mStatesCnt);
+    LineNumbersState* s2 = Unit->mStates;
+    for (i = 1, j = 0; i < Unit->mStatesCnt; i++) {
+        LineNumbersState* s1 = Unit->mStates + i;
+        if (s1->mLine != s2->mLine || s1->mColumn != s2->mColumn ||
+            s1->mFile != s2->mFile ||
+            s1->mFlags != s2->mFlags || s1->mISA != s2->mISA ||
+            s1->mOpIndex != s2->mOpIndex || s1->mDiscriminator !=
s2->mDiscriminator) {
+            Unit->mStatesIndex[j++] = s2;
+        }
+        s2 = s1;
+    }
+    for (i = 0; i < j; i++) {
+        memmove(Unit->mStates + i, Unit->mStatesIndex[i],
sizeof(LineNumbersState));
+        Unit->mStatesIndex[i] = Unit->mStates + i;
+    }
+    Unit->mStatesCnt = j;
     qsort(Unit->mStatesIndex, Unit->mStatesCnt, sizeof(LineNumbersState *), state_text_pos_comparator);
     for (i = 0; i < Unit->mStatesCnt; i++)
Unit->mStatesIndex[i]->mStatesIndexPos = i;
     if (Cache->mFileInfoHash == NULL) {
--
_______________________________________________
tcf-dev mailing list
tcf-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/tcf-dev


Back to the top