[Mono-dev] mcs patch to say goodbye to SeekableStreamReader
atsushi at ximian.com
Wed Aug 31 00:04:37 EDT 2005
Thanks to Kornél's msg I noticed that I shouldn't reset cached token
on identifier "partial". Thus I created fixed patch.
>> Now I blame SeekableStreamReader on bringing UTF8 related bug
>> (without proof ;-) so I made a patch to eliminate this class.
>> Additionally I made tiny modification for 'MZ' executable check
>> (even with a test case bom-mz.cs that differentiates csc and mcs).
>> I'm not sure if it really is the culprit, but now we don't have
>> tricky stream usage, so now the code should be a bit healthy.
> In general adding more tests to the xtoken() routine hurts performance,
> that is why we have avoided it. I also believe that the new code is a
> bit more difficult to follow: just how many saved variables are we going
> to have?
I agree that xtoken() could be performance sensitive, but on the
other hand, current code moves back the stream, which results in
extraneous parse on every parenthesized expressions. Actually
as mentioned later, the patched code seems faster. Note that
SeekableStreamReader has to call encoding GetCharCount() when
we reposition the stream.
For complexity, SeekableStreamReader is much more difficult to
debug; it requires us to debug not only tokenizer but also
Stream repositioning, Encoding conversion sanity, relationship
between Stream repositioning and conversion in-process bytes
I needed to introduce just one cached token and one boolean flag
to support putback from parser (the latter one is required because
there could be another putback_char).
> Before we can do something about this, I would like two tests to be
> time mcs --parse sourcefiles
> Where sourcefiles means a lot of source code, measure before and after.
> Then we should measure the impact of the allocation of SavedToken with
> mono --profile before and after.
Actually the resulting performance is better than existing code:
existing code at *best*:
Total memory allocated: 34835 KB
patched code at *worst*:
Total memory allocated: 34083 KB
Most of the memory consumption difference comes from
731 KB Mono.CSharp.SeekableStreamReader::.ctor(StreamReader)
731 KB 363 System.Char
Callers (with count) that contribute at least for 1%:
363 100 % Mono.CSharp.SeekableStreamReader::.ctor(Stream,Encoding)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Mono-devel-list