Hello
Francois,
The problem is that it's easy to use if
you have an event stream where each event is equal in size and you can
position it by simply setting the stream position and searching can be done
by multiplication by the event size.
but when the stream holds
variable-sized events this solution enforces that each event within the
large file has to be searched from the very beginning. Of course it would be
possible to store the stream position in the location object, but for each
parseEvent I would have to call seekLocation and this would then have to
count the variable size events starting from the last well known stored
position.
I'm not sure if that's possible in Java
but we can overcome the concurrency problem by using something like
thread-local storage in C/C++. When the location object would have multiple
faces for each thread the problem of concurrency would be
solved.
Maybe the location object can be a stub
which will handle each of the thread location requests
separately.
The problem with the specification that
the location has to match the returned event is that it breaks your concept
of the indexing. You are making copies of the contexts for the index, but
you are returning the very same location objects to parse event which will
modify the location and will therefore also modify the object in the index
map. Or have I overseen something?
Best regards,
Franz
Hi Franz,
See my answers below.
Best Regards,
/fc
From: Polzer, Franz
[mailto:Franz_Polzer@xxxxxxxxxx]
Sent: October-15-09 3:22
AM
To: Francois Chouinard
Cc: Kreutzer,
Manfred
Subject: RE: TMF question
Hello Francois,
Please correct me when I’m
wrong:
- seekLocation returns a
context at the given location (the context contains a user-defineable
location object that might be used for fast positioning the
stream)
- parseEvent returns the
current event and advances the context to the next
event.
Correct.
My understanding of how
parseEvent works is that it takes the context, reads the event at the
context’s position and advances the context to the next event to be read.
The LTTng sample implementation calls seekLocation every time in the
parseEvent method which should not be needed from my point of view because
the context should point to the correct location in the file(s) using the
user-defined location object.
Not exactly. Unfortunaltely, multiple clients
(views, etc) might access the same trace concurrently but for different
locations. You can see what kind of problems this can cause: it can not be
guaranteed that the trace pointer has not been modified by a concurrent
thread between 2 calls to parseEvent(). Therefore, within parseEvent(),
the trace has to be positionned synchronously and something
equivalent to a call to seekLocation() is
required.
BTW, LTTng does a quick test for the current
position in seekLocation() and does nothing if the steam is already at the
right place. This is a quick test that could easily be migrated in the
framerwork, assuming that the concrete Trace class can implement a the
correct predicate (current location == requested
location).
But I agree that this is not a very pretty piece of
code and that uncontroled concurrency causes all kinds of bad delays
when simultaneous accesses are enabled. I intended to mitigate the issues
with caches but I'm not sure it will be enough :-( Another thing
I'm looking into is request coalescing which should also help. If you have
other ideas, they are welcome!
But I encountered that this is not possible to use
parseEvent without calling seekLocation because when the framework
positions the traces it makes a copy of the TmfTraceContext but it makes
no copy of the user-defined location objects inside this
context.
Hummm, I'm not sure of that: the
TmfTraceContext copy constructor does not clone the location (which it
should...) but definitely stores it (not my best idea). As you already
figured out, the context is used to reposition the trace correctly before a
parse/read. I might have missed something but if you found a place where the
location is not set properly, please let me know (that would likelybe an
error).
What does not show too much in the code comments is
that the location can be a tricky thing: in the case of LTTng, the library
uses the timestamp as the location while more "standard" trace/log
types would use stream offset or something similar. TmfTraceContext has
this constraint that its location has to correspond to the event with the
given timestamp (and index...) which is delicate to handle without
affecting the LTTng parsing library performance. In fact, I had to hack
the code to make it work properly for LTTng and I now have to seriously
revisit this part.
It would be much more efficient when the framework
would also copy the user-defined location object inside the context when
making a copy of the context because then no seek is needed in parse
Event. The framework would set the new context using the positionTraces
method and call parse event. And the context would be already positioned
at the correct position that the user-implemented stream would need to
read the next event. And when the event is read the parse event will also
modify the user-defined location to the next event to be read. Working
this way would remove a lot of unnecessary seekLocation calls during the
event parsing stage.
What do you
think?
It would be so much easier without concurrency :-)
Unfortunately, I don't have yet a good, generic solution for this and
I'm not sure I want to sacrifice UI responsiveness. But this is definitely
an area that has to be worked
on.
By the way – do you have any
new model documentation as you mentioned last week?
Working on
it...
Best
regards,
Franz
Polzer
SW
Development Engineer
Embedded Systems
Division
Mentor Graphics
Corporation
www.mentor.com/embedded
From: Francois Chouinard
[mailto:francois.chouinard@xxxxxxxxxxxx]
Sent: Thursday, October 08, 2009 4:05
PM
To: Polzer,
Franz
Cc: Kreutzer,
Manfred
Subject: RE: TMF
question
You are
absolutely right and this is one of the very first "improvements" that we
will address as soon as we are done with the initial release of LTTng (due
tomorow :-).
I expect to
have something early next week. I will be happy to forward you the
updated model doc for comments.
From: Polzer, Franz
[mailto:Franz_Polzer@xxxxxxxxxx]
Sent: October-08-09 5:13
AM
To: Francois
Chouinard
Cc: Kreutzer,
Manfred
Subject: TMF
question
Hello,
I’m trying to use the TMF
classes.
The TmfEventContent is used
to store the trace content data and the TmfEventField is used to provide
the GUI representation of this content. My problem is that the
TmfEventContent stores the event data content internally already as
parsed string.
I wanted to know why the
design was done that way. From my point of understanding I would create
a TmfEventContent providing a content object that the TmfEventFormat can
split up into fields. But in the current TMF implementation the
TmfEventContent is calling .toString() and stores the returned string
instead of the raw data. Wouldn’t it be more useful when the
TmfEventContent object would store the original given content object as
Java object and the TmfEventFormat will split up the data either binary
or by using .toString()? This would allow more flexibility in the usage
of the content/format pair and would also improve performance when no
string parsing needs to be done by the TmfEventFormat
object.
Best
regards,
Franz
Polzer
SW
Development Engineer
Embedded
Systems Division
Mentor Graphics
Corporation
www.mentor.com/embedded