dconf dod parser is 20% slower thoery

Robert Schadek rburners at gmail.com
Fri Jul 18 08:53:23 UTC 2025


On Monday, 14 July 2025 at 08:01:42 UTC, monkyyy wrote:

Thank you for taking an interest.

I thought about this a bit more and I think one issue is also 
that stuff is loaded one L1 cache line at a time, and the .sizeof 
of each struct is a lot small than one L1 cache line. Leading to 
waste. The parse tree being a tree will likely require quite a 
bit of index/pointer chasing. Resulting in more loads.

That begin said, what would be a nice try is to turn this.

```d
struct Parser {
	Document[] documents;
	Definitions[] definitionss;
	Definition[] definitions;
	OperationDefinition[] operationDefinitions;
	SelectionSet[] selectionSets;
}
```

into

```d
alias Nodes = SumType!(Document
, Definitions
, Definition
, OperationDefinition
, SelectionSet);

struct Parser {
   Nodes[] nodes;
}
```

The problem then is that the tree turned into an array should be 
accessed basically front to back to minimize cache misses. That 
might be difficult as its a tree, but hey, there is always 
something. If you're interested the parser generator branch that 
gives the individual structs is here 
https://github.com/burner/Darser/tree/ddd_parser


More information about the Digitalmars-d mailing list