[antlr-interest] Re: trees with payloads??
John D. Mitchell
johnm-antlr at non.net
Thu Nov 11 10:15:34 PST 2004
>>>>> "lgcraymer" == lgcraymer <lgc at mail1.jpl.nasa.gov> writes:
>>>>>> In antlr-interest at yahoogroups.com, "micheal_jor" <open.zone at v...>
[...]
>> Yep, right you are. Performance tuning is hard. You would typically
>> need to copy selected substrings from the input buffer to another buffer
>> where the start/end indices refer. Else, you might end up keeping a
>> 100kB memory-mapped file hanging around just for the sake of a few
>> substrings.
> True, but a 100KB or even 100 MB memory-mapped file is not a big
> expense--the OS virtual memory management takes care of that. If you
> only keep a few strings, then you only keep a few blocks of the file
> memory-resident. On the other hand, 20,000 string copies and creates (5
> chars per word, which is probably an overestimate) is a performance hit.
It's pretty easily conceivable that there are some uses and/or platforms
for which that kind of memory lingering is a problem. I think there is a
relatively simple solution...
At the end of each translation phase, you should be able to manually invoke
an explicit copy-forward of all of the data referenced by a given root
node. After you do that, you can e.g., invoke the garbage collector, unpin
the file, etc.
Doing that after a lexer which discards a lot of stuff (i.e., a traditional
source to object code compiler) would potentially free up a lot of memory.
Since it's optional and manually induced, the developer gets the option of
invoking it. [Though, of course, a code generator could be tweaked to spit
that out automagically.]
Take care,
John
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list