modification to architecture and implementation
[lttv.git] / ltt / branches / poly / doc / developer / lttvwindow_events_delivery.txt
CommitLineData
6ea2aecb 1Linux Trace Toolkit
2
3Mathieu Desnoyers 17-05-2004
4
5
6This document explains how the lttvwindow API could process the event requests
7of the viewers, merging event requests and hook lists to benefit from the fact
8that process_traceset can call multiple hooks for the same event.
9
10First, we will explain the detailed process of event delivery in the current
11framework. We will then study its strengths and weaknesses.
12
13In a second time, a framework where the events requests are dealt by the main
14window with fine granularity will be described. We will then discussed the
15advantages and inconvenients over the first framework.
16
17
181. (Actual) Boundaryless event reading
19
20Actually, viewers request events in a time interval from the main window. They
21also specify a (not so) maximum number of events to be delivered. In fact, the
22number of events to read only gives a stop point, from where only events with
23the same timestamp will be delivered.
24
25Viewers register hooks themselves in the traceset context. When merging read
26requests in the main window, all hooks registered by viewers will be called for
27the union of all the read requests, because the main window has no control on
28hook registration.
29
30The main window calls process_traceset on its own for all the intervals
31requested by all the viewers. It must not duplicate a read of the same time
32interval : it could be very hard to filter by viewers. So, in order to achieve
33this, time requests are sorted by start time, and process_traceset is called for
34each time request. We keep the last event time between each read : if the start
35time of the next read is lower than the time reached, we continue the reading
36from the actual position.
37
38We deal with specific number of events requests (infinite end time) by
39garantying that, starting from the time start of the request, at least that
40number of events will be read. As we can't do it efficiently without interacting
41very closely with process_traceset, we always read the specified number of
42events requested starting from the current position when we answer to a request
43based on the number of events.
44
45The viewers have to filter events delivered by traceset reading, because they
46can be asked by another viewer for a totally (or partially) different time
47interval.
48
49
50Weaknesses
51
52- process_middle does not guarantee the number of events read
53
54First of all, a viewer that requests events to process_traceset has no garantee
55that it will get exactly what it asked for. For example, a direct call to
56traceset_middle for a specific number of events will delived _at least_ that
57quantity of events, plus the ones that have the same timestamp that the last one
58has.
59
60- Border effects
61
62Viewer's writers will have to deal with a lot of border effects caused by the
63particularities of the reading by selecting the information.
64
65- Lack of encapsulation
66
67The viewer's writer will have to take into account all the border effects caused
68by the interaction with other modules. This means that event if a viewer works
69well alone or with another viewer, it's possible that new bugs arises when a new
70viewer comes around.
71
72
73- Duplication of the work
74
75Time based filters and counters of events will have to be implemented at the
76viewer's side, which is a duplication of the functionnalities that would
77normally be expected from the tracecontext API.
78
79- Lack of control over the data input
80
81As we expect module's writers to prefer to be as close as possible from the raw
82datas, making them interact with a lower level library that gives them a data
83input that they only control by further filtering of the input is not
84appropriated. We should expect some reluctancy from them about using this API
85because of this lack of control on the input.
86
87- Speed cost
88
89All hooks of all viewers will be called for all the time intervals. So, if we
90have a detailed events list and a control flow view, asking both for different
91time intervals, the detailed events list will have to filter all the events
92delivered originally to the control flow view. This can be a case occuring quite
93often.
94
95
96
97Strengths
98
99- Simple concatenation of time intervals at the main window level.
100
101Having the opportunity of delivering more events than necessary to the viewers
102means that we can concatenate time intervals and number of events requested
103fairly easily, while being hard to determine if some specific cases will be
104wrong by formal methods.
105
106- No duplication of the tracecontext API
107
108Viewers deal directly with the tracecontext API for registering hooks, removing
109a layer of encapsulation.
110
111
112
113
114
1152. (Proposed) Strict boundaries events reading
116
117The idea behind this method is to provide exactly the events requested by the
118viewers to them, no more, no less.
119
120This method relies on the fact that time based and number based event requests
121are, by nature, totally different and that there is no real interest in merging
122both requests types.
123
124It uses the new API for process traceset suggested in the document
125process_traceset_strict_boundaries.txt.
126
127It also means that the lttvwindow API will have to deal with viewer's hooks.
128Those will not be allowed to add them directly in the context. They will give
129them to the lttvwindow API, along with the time interval or the position and
130number of events. The lttvwindow API will have to take care of adding and
131removing hooks for the different time intervals requested. That means that hooks
132insertion and removal will be done between each traceset processing based on
133the time intervals and event positions related to each hook. We must therefore
134provide a simple interface for hooks passing between the viewers and the main
135window, make them easier to manage from the main window. The new type
136LttvHooksPrio solves this problem.
137
138
139Architecture
140
141Added to the lttvwindow API :
142
143
144- lttvwindow_time_interval_request
145arguments :
146( MainWindow *main_win,
147 TimeWindow time_requested, guint num_events,
148 LttvHooksPrio process_traceset_middle,
149 LttvHook after_process_traceset,
150 gpointer after_process_traceset_data);
151
152- lttvwindow_position_request
153arguments :
154( MainWindow *main_win,
155 LttvTracesetPosition position, guint max_num_events,
156 LttvHooksPrio process_traceset_middle,
157 LttvHook after_process_traceset,
158 gpointer after_process_traceset_data);
159
160
161Internal functions :
162
163- lttvwindow_process_pending_requests
164
165
166
167Implementation
168
169
170- Type LttvHooksPrio
171
6d917c2c 172see hook_prio.txt
6ea2aecb 173
174
175- lttvwindow_time_interval_request
176
177It adds the TimeRequest struct to the array of time requests pending and
178registers a pending request for the next g_idle if none is registered.
179
180typedef struct _TimeRequest {
181 TimeWindow time_window;
182 guint num_events;
183 LttvHooksPrio middle_hooks;
184 LttvHook after_hook;
185 gpointer after_hook_data;
186} TimeRequest;
187
188
189- lttvwindow_position_request
190
191It adds a PositionRequest struct to the array of position requests pending and
192registers a pending request for the next g_idle if none is registered.
193
194typedef struct _PositionRequest {
195 LttvTracesetPosition position;
196 guint max_num_events;
197 LttvHooksPrio middle_hooks;
198 LttvHook after_hook;
199 gpointer after_hook_data;
200} PositionRequest;
201
202
203
204- lttvwindow_process_pending_requests
205
206This internal function gets called by g_idle, taking care of the pending
207requests. It is responsible for concatenation of time intervals and position
208requests. It does it while it calls process traceset. Here is the detailed
209description of the way it works :
210
211It treats time interval requests and position requests as two different cases.
212So let's start with time interval requests.
213
214- Time interval requests servicing
215
216(1)
217It starts by finding the time interval request with the lowest start time and
218the others with the same start time. It add its (or their) hooks to the context.
219It will use this start time to seek in the traceset.
220
221Then, it searches for what event comes first : the end of one of the time
222request actually added in the context or the start of a time request that is not
223in the context. It uses this value as a end boundary for the first process
224traceset middle call.
225
226After a process traceset middle ends, we check if we have reached the end time
227of any time request. If so, we call the time requests process traceset end hook
228and remove this time request from the context and the array of time requests. If
229the context has no hooks left, that means that we have to jump further in the
230traceset. We then simply have to use the exact routine that we used for (1).
231
232Else, if there are hooks left, that means that we have not finished requesting
233one hook's time interval request yet, but maybe we must add a new time request
234to the hook list of the context. We start back at point (1), except that instead
235of finding the lowest start time, we simply keep the hooks already present in
236the context and add hooks that has their start time with a value equal to the
237last process traceset's end time.
238
239
240- Position requests servicing
241
242As it is nearly impossible to compare two traceset positions without replaying
243part of the traceset reading, which is not very efficient, we consider that the
244performance cost of doing one trace read per request does not justify position
245requests combinations. So, each position request will be serviced independently.
246
247
248
249
250Weaknesses
251
252- Position requests are serviced independently, which may duplicate traceset
253reads.
254
255
256
257Strengths
258
259- Removes the need for filtering of information supplied to the viewers.
260
261- Viewers have a better control on their data input.
262
263- Solves all the weaknesses idenfied in the actual boundaryless traceset
264reading.
This page took 0.031888 seconds and 4 git commands to generate.