[Oberon] Why is RSC string data word-aligned?

Colby Russell oberon at x.colbyrussell.com
Sun Jan 31 01:25:06 CET 2021


On 1/30/21 5:44 PM, Chris Burrows wrote:
 >> Colby Russell
 >> Sent: Sunday, 31 January 2021 8:22 AM
[...]
 >> <https://hypothes.is/a/Wx_nmmNEEeuHEi-6X3lPnQ>
 >>
 >> It appears this is an (unnoticed?) opportunity for further
 >> optimization of the Oberon system.  The caveat being that it
 >> constitutes a breaking change to the RSC file format.  So perhaps
 >> Wirth has noticed and just decided that it wasn't worth the trouble?
 >>
 >
 > I checked a couple of the compiler modules (ORP and ORS) and the 
number of
 > nulls in strings in the object file is about 1% of the total file size

I don't mention is as a concern for file size, but as I mentioned in the
Hypothesis annotation, as a matter of efficiency.  The choice to align
on word boundaries is (presumably) for reasons of efficiency.  But by
doing the alignment in the object file itself rather than in the module
loader, whatever efficiency is sought is surely overwhelmed by the fact
that many more cycles are wasted by the spurious character reads than the
number of cycles saved, no?  Every padding byte in the object file 
results in
more time spent in the read loop and extra calls to `Files.Read`, 
slowing down
the module loader.

The fact that this situation (probably) arose out of trying to optimize for
memory access could be an example of Knuth's adage that "premature
optimization is the root of all evil"--many more cycles are wasted 
(including
memory reads) than in the naive implementation where there was no attempt to
optimize.

-- 
Colby Russell


More information about the Oberon mailing list