Skip to content

Commit

Permalink
Fix: consider index of all files for data stream groups with multiple…
Browse files Browse the repository at this point in the history
… files

The indexes associated to data stream file groups (dsfg) with multiple
files are incorrect.

The first time we process a file for a given dsfg, the group is created
using the index of that file.  Up to that point, it's fine.  When
processing the other files for that dsfg, the index is never used.  The
result is that the index for that dsfg only covers the time range of the
first file that was parsed, instead of the whole data stream.

Fix it by merging the index of the added file in
add_ds_file_to_ds_file_group, in the case where we add the file to an
existing group.

A test is added for this, in the form of a trace infos query.  The
implementation of this query uses the index data directly.

Change-Id: If1afd68be347210d1e258f8115b50547bc773760
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2212
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
  • Loading branch information
simark committed Oct 18, 2019
1 parent 5687169 commit ce75de1
Show file tree
Hide file tree
Showing 29 changed files with 125,499 additions and 20 deletions.
46 changes: 28 additions & 18 deletions src/plugins/ctf/fs-src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,23 +678,42 @@ void ds_file_group_insert_ds_file_info_sorted(
}

static
void ds_file_group_insert_ds_index_entry_sorted(
struct ctf_fs_ds_file_group *ds_file_group,
void ds_index_insert_ds_index_entry_sorted(
struct ctf_fs_ds_index *index,
struct ctf_fs_ds_index_entry *entry)
{
guint i;

/* Find the spot where to insert this index entry. */
for (i = 0; i < ds_file_group->index->entries->len; i++) {
struct ctf_fs_ds_index_entry *other_entry = g_ptr_array_index(
ds_file_group->index->entries, i);
for (i = 0; i < index->entries->len; i++) {
struct ctf_fs_ds_index_entry *other_entry =
g_ptr_array_index(index->entries, i);

if (entry->timestamp_begin_ns < other_entry->timestamp_begin_ns) {
break;
}
}

array_insert(ds_file_group->index->entries, entry, i);
array_insert(index->entries, entry, i);
}

static
void merge_ctf_fs_ds_indexes(struct ctf_fs_ds_index *dest, struct ctf_fs_ds_index *src)
{
guint i;

for (i = 0; i < src->entries->len; i++) {
struct ctf_fs_ds_index_entry *entry =
g_ptr_array_index(src->entries, i);

/*
* Ownership of the ctf_fs_ds_index_entry is transferred to
* dest.
*/
g_ptr_array_index(src->entries, i) = NULL;

ds_index_insert_ds_index_entry_sorted(dest, entry);
}
}

static
Expand Down Expand Up @@ -829,6 +848,8 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
}

add_group = true;
} else {
merge_ctf_fs_ds_indexes(ds_file_group->index, index);
}

ds_file_group_insert_ds_file_info_sorted(ds_file_group, ds_file_info);
Expand Down Expand Up @@ -1226,18 +1247,7 @@ void merge_ctf_fs_ds_file_groups(struct ctf_fs_ds_file_group *dest, struct ctf_f
}

/* Merge both indexes. */
for (i = 0; i < src->index->entries->len; i++) {
struct ctf_fs_ds_index_entry *entry = g_ptr_array_index(
src->index->entries, i);

/*
* Ownership of the ctf_fs_ds_index_entry is transferred to
* dest.
*/
g_ptr_array_index(src->index->entries, i) = NULL;

ds_file_group_insert_ds_index_entry_sorted(dest, entry);
}
merge_ctf_fs_ds_indexes(dest->index, src->index);
}
/* Merge src_trace's data stream file groups into dest_trace's. */

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ctf/fs-src/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct ctf_fs_ds_index_entry {
};

struct ctf_fs_ds_index {
/* Array of pointer to struct ctf_fs_fd_index_entry. */
/* Array of pointer to struct ctf_fs_ds_index_entry. */
GPtrArray *entries;
};

Expand Down
10 changes: 10 additions & 0 deletions tests/data/ctf-traces/succeed/lttng-tracefile-rotation/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Trace created with:

lttng create
lttng enable-channel --kernel --tracefile-size=64k --subbuf-size=64k mychan
lttng enable-event -k --channel=mychan 'sched_*'
lttng start
sleep 2
lttng stop


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ce75de1

Please sign in to comment.