[Issue 24700] New: MsCoffObj_getsegment is really slow O(n^2)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 13 11:00:50 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24700

          Issue ID: 24700
           Summary: MsCoffObj_getsegment is really slow O(n^2)
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: industry
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

Code generation of an internal dub project at SARC takes way longer than
necessary:

objflush_pointerRefs is called on an .obj file with ~4600 000 pointer refs.
This calls MsCoffObj_getsegment(".dp$B") for each of them, which does a linear
scan over all sections:

```
for (segidx_t seg = 1; seg < SegData.length; seg++)
{
     if (strcmp(...))
         ...       
```

https://github.com/dlang/dmd/blob/05b2c0dfe27f0797151e7c6f7c7db43f700c1edc/compiler/src/dmd/backend/mscoffobj.d#L1364

SegData.length is 61000 here.

ElfObj_getsegment uses a hash table for this, MsCoff_getsegment should do this
as well.

--


More information about the Digitalmars-d-bugs mailing list