Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tracecompass-dev] [lttng-dev] Scalability

I have attached the C file for a generator that creates a trace that reproduces the memory issue with babeltrace. The same issue happens with a custom program in the call to add a trace to a context.

I am using babeltrace that I get from my Ubuntu 18.04 distro. It has the version number 1.5.5.

Thanks for the help!

On Tue, 2019-03-12 at 15:47 +0000, Doug Schaefer wrote:
In the thread on the tracecompass list, I also mentioned that the babeltrace utility itself ran out of memory when reading the file. That's actually my biggest worry. I got around the generator issue by flushing every 100K events.

I'll create a quick generator that shows the same issue and post it in a bit.

Doug.

On Tue, 2019-03-12 at 11:34 -0400, Jonathan Rajotte-Julien wrote:
On Tue, Mar 12, 2019 at 03:23:23PM +0000, Doug Schaefer wrote:

It should be easy to generate a random one with the class I mentioned below
and fill it with 16 million events.

Not if the problem is in the generator code ;).


BTW, two of the int fields are 5 and 10
bits respectively, but I'm not sure that matters (or at least it shouldn't).

Make sure to check the endian-ness of those fields.

What class? Not sure I see any reference to any.

Since you are generating CTF the error can be in the generator code. Please
provide either a trace reproducing the issue or a base reproducer. It will be
much easier overall than us trying to reproduce it blindly.

Cheers.

_______________________________________________
lttng-dev mailing list
lttng-dev@xxxxxxxxxxxxxxx
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.lttng.org_cgi-2Dbin_mailman_listinfo_lttng-2Ddev&d=DwICAg&c=yzoHOc_ZK-sxl-kfGNSEvlJYanssXN3q-lhj0sp26wE&r=NrrbvTHWa2Nbp_kAN0Hl1o3lM1WAwSes64uBjxjNhMc&m=DWwlFfl5FD5R8-HPY3GfbG6l6m7y_o2gXPER8IkQstk&s=bPK6X3vufUtEAemGpslNIlIL4UslBsgK-SWnraL-e9g&e=

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
#include <babeltrace/context.h>
#include <babeltrace/ctf-ir/clock.h>
#include <babeltrace/ctf-ir/event-class.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-writer/event.h>
#include <babeltrace/ctf-writer/event-fields.h>
#include <babeltrace/ctf-writer/stream-class.h>
#include <babeltrace/ctf-writer/stream.h>
#include <babeltrace/ctf-writer/writer.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

#define CHECK(call) \
    if ((call) < 0) { \
        fprintf(stderr, "failed %s:%d %s\n", __func__, __LINE__, #call); \
        exit(1); \
    }

#define NULLCHECK(ptr) \
    if ((ptr) == NULL) { \
        fprintf(stderr, "failed %s:%d %s\n", __func__, __LINE__, #ptr); \
        exit(1); \
    }

int main(int argc, char *argv[])
{
    struct bt_ctf_writer *writer = bt_ctf_writer_create("scaletest.ctf");
    NULLCHECK(writer);

    struct bt_ctf_clock *clock = bt_ctf_clock_create("simple_clock");
    NULLCHECK(clock);
    CHECK(bt_ctf_clock_set_description(clock, "simple clock, really"));
    CHECK(bt_ctf_writer_add_clock(writer, clock));

    struct bt_ctf_stream_class *scale_stream_class = bt_ctf_stream_class_create("scale_stream");
    NULLCHECK(scale_stream_class);
    CHECK(bt_ctf_stream_class_set_clock(scale_stream_class, clock));

    // simple class
    struct bt_ctf_event_class *simple_event_class = bt_ctf_event_class_create("simple");
    NULLCHECK(simple_event_class);

    struct bt_ctf_field_type *cpu_type = bt_ctf_field_type_integer_create(6);
    NULLCHECK(cpu_type);
    CHECK(bt_ctf_field_type_integer_set_signed(cpu_type, 0));
    CHECK(bt_ctf_event_class_add_field(simple_event_class, cpu_type, "cpu"));

    struct bt_ctf_field_type *class_type = bt_ctf_field_type_integer_create(5);
    NULLCHECK(class_type);
    CHECK(bt_ctf_field_type_integer_set_signed(class_type, 0));
    CHECK(bt_ctf_event_class_add_field(simple_event_class, class_type, "class"));

    struct bt_ctf_field_type *type_type = bt_ctf_field_type_integer_create(10);
    NULLCHECK(type_type);
    CHECK(bt_ctf_field_type_integer_set_signed(type_type, 0));
    CHECK(bt_ctf_event_class_add_field(simple_event_class, type_type, "type"));

    struct bt_ctf_field_type *data_length_type = bt_ctf_field_type_integer_create(32);
    NULLCHECK(data_length_type);
    CHECK(bt_ctf_field_type_integer_set_signed(data_length_type, 0));
    CHECK(bt_ctf_event_class_add_field(simple_event_class, data_length_type, "data_length"));

    struct bt_ctf_field_type *data_element_type = bt_ctf_field_type_integer_create(32);
    NULLCHECK(data_element_type);
    CHECK(bt_ctf_field_type_integer_set_signed(data_element_type, 0));
    struct bt_ctf_field_type *data_type = bt_ctf_field_type_sequence_create(data_element_type, "data_length");
    NULLCHECK(data_type);
    CHECK(bt_ctf_event_class_add_field(simple_event_class, data_type, "data"));

    CHECK(bt_ctf_stream_class_add_event_class(scale_stream_class, simple_event_class));

    struct bt_ctf_stream *stream = bt_ctf_writer_create_stream(writer, scale_stream_class);
    NULLCHECK(stream);

    uint64_t time = 10000000;

    for (int i = 0; i < 16000000; i++) {
        if (i % 100000 == 0) {
            printf("event %d\n", i);
            CHECK(bt_ctf_stream_flush(stream));
        }

        CHECK(bt_ctf_clock_set_time(clock, time++));

        struct bt_ctf_event *event = bt_ctf_event_create(simple_event_class);
        NULLCHECK(event);

        struct bt_ctf_field *cpu_field = bt_ctf_field_create(cpu_type);
        NULLCHECK(cpu_field);
        CHECK(bt_ctf_field_unsigned_integer_set_value(cpu_field, 0));
        CHECK(bt_ctf_event_set_payload(event, "cpu", cpu_field));
        bt_ctf_field_put(cpu_field);

        struct bt_ctf_field *class_field = bt_ctf_field_create(class_type);
        NULLCHECK(class_field);
        CHECK(bt_ctf_field_unsigned_integer_set_value(class_field, 0));
        CHECK(bt_ctf_event_set_payload(event, "class", class_field));
        bt_ctf_field_put(class_field);

        struct bt_ctf_field *type_field = bt_ctf_field_create(type_type);
        NULLCHECK(type_field);
        CHECK(bt_ctf_field_unsigned_integer_set_value(type_field, 0));
        CHECK(bt_ctf_event_set_payload(event, "type", type_field));
        bt_ctf_field_put(type_field);

        size_t data_length = 2;
        struct bt_ctf_field *data_length_field = bt_ctf_field_create(data_length_type);
        NULLCHECK(data_length_field);
        CHECK(bt_ctf_field_unsigned_integer_set_value(data_length_field, data_length));
        CHECK(bt_ctf_event_set_payload(event, "data_length", data_length_field));

        struct bt_ctf_field *data_field = bt_ctf_field_create(data_type);
        NULLCHECK(data_field);
        CHECK(bt_ctf_field_sequence_set_length(data_field, data_length_field));
        for (uint64_t j = 0; j < data_length; j++) {
            struct bt_ctf_field *data_element_field = bt_ctf_field_sequence_get_field(data_field, j);
            NULLCHECK(data_element_field);
            CHECK(bt_ctf_field_unsigned_integer_set_value(data_element_field, 0));
            bt_ctf_field_put(data_element_field);
        }
        CHECK(bt_ctf_event_set_payload(event, "data", data_field));
        bt_ctf_field_put(data_length_field);
        bt_ctf_field_put(data_field);

        CHECK(bt_ctf_stream_append_event(stream, event));

        bt_ctf_event_put(event);
    }

    CHECK(bt_ctf_stream_flush(stream));
    bt_ctf_writer_flush_metadata(writer);
    return 0;
}

Back to the top