reduce Loc.sizeof by 8 bytes#15199
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#15199" |
2cfe6bc to
7d8e4bc
Compare
|
I have also looked into doing this, but didn't get around to implementing it in a PR yet. Nice work!
Yes, last time I checked, 40 out of 440 MB RAM was spent on
Indeed. One way to do this is to make a However, that puts a limit of 4GB on the input source code per compiler invocation. That should be enough for anyone today, but I can imagine someone is going to hit that some day. |
| //printf("setting %s\n", name); | ||
| filenames.push(name); | ||
| fileIndex = cast(ushort)filenames.length; | ||
| assert(fileIndex); // no overflow |
There was a problem hiding this comment.
Won't this result in many duplicates?
There was a problem hiding this comment.
Ironically, no, for the same reason the lexer doesn't lex the same file multiple times.
7f3ce4b to
f1445c9
Compare
|
[I think shrinking it further to 4 bytes would have much less of an impact, as we'd need to additionally check for field placements - e.g. |
f1445c9 to
ce58b6c
Compare
* Print an ICE message for Loc.filename overflows * Increase the Loc size again, raising the file name limit from 64K to 4G but keeping the index indirection from dlang#15199. The `Loc` size for DMD-as-a-library is 16 bytes then, and 12 bytes otherwise.
* Print an ICE message for Loc.filename overflows * Increase the Loc size again, raising the file name limit from 64K to 4G but keeping the index indirection from dlang#15199. The `Loc` size for DMD-as-a-library is 16 bytes then, and 12 bytes otherwise.
* Print an ICE message for Loc.filename overflows * Increase the Loc size again, raising the file name limit from 64K to 4G but keeping the index indirection from #15199. The `Loc` size for DMD-as-a-library is 16 bytes then, and 12 bytes otherwise.
by replacing the pointer to a filename string with a ushort index into an array.
Also reduced the column number to a ushort, because 65,000 character lines is good enough for anyone.
Could probably convert all filename pointers to an index.
Since Loc is used everywhere, this should have a decent impact.
We could get the size to 4 bytes if willing to restrict the number of lines, chars, and files.