Skip to content

Commit

Permalink
Initial zstd compression #50
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesart committed Nov 12, 2022
1 parent 5701fb6 commit ea0bd3c
Show file tree
Hide file tree
Showing 25 changed files with 17,228 additions and 1,723 deletions.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
_release/*
_debug/*
build/*
traces_x/*
traces_intel/*
lib/

tags*

sample/_release/*
sample/_debug/*

qtcreator/gpuvis.creator.user*
qtcreator/gpuvis.config
qtcreator/gpuvis.creator
qtcreator/gpuvis.files
qtcreator/gpuvis.includes
35 changes: 32 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ LIBS = -Wl,--no-as-needed -lm -ldl -lpthread -lstdc++
CFLAGS += $(shell sdl2-config --cflags)
LIBS += $(shell sdl2-config --libs)

CFLAGS += $(shell pkg-config --cflags libzstd) -DHAVE_ZSTD
LIBS += $(shell pkg-config --libs libzstd)
CFLAGS += $(shell pkg-config --cflags zlib) -DHAVE_ZLIB
LIBS += $(shell pkg-config --libs zlib)

ifeq ($(USE_GTK3), 1)
CFLAGS += $(shell pkg-config --cflags gtk+-3.0) -DUSE_GTK3
endif
Expand All @@ -89,7 +94,12 @@ endif
CFLAGS += $(shell pkg-config --cflags freetype2)
LIBS += $(shell pkg-config --libs freetype2)

CFLAGS += -Isrc/libtraceevent/include
CFLAGS += \
-I./src/libtraceevent/include \
-I./src/libtraceevent/src \
-I./src/trace-cmd/include \
-I./src/trace-cmd/include/trace-cmd \
-I./src/libtracefs/include

ifneq ("$(wildcard /usr/bin/ld.gold)","")
$(info Using gold linker...)
Expand All @@ -109,6 +119,7 @@ CFILES = \
src/gpuvis_graphrows.cpp \
src/gpuvis_ftrace_print.cpp \
src/gpuvis_utils.cpp \
src/gpuvis_i915_perfcounters.cpp \
src/tdopexpr.cpp \
src/ya_getopt.c \
src/MurmurHash3.cpp \
Expand All @@ -118,17 +129,29 @@ CFILES = \
src/imgui/imgui.cpp \
src/imgui/imgui_demo.cpp \
src/imgui/imgui_draw.cpp \
src/imgui/imgui_freetype.cpp \
src/GL/gl3w.c \
src/i915-perf/i915-perf-read.cpp \
src/libtraceevent/src/event-parse.c \
src/libtraceevent/src/event-parse-api.c \
src/libtraceevent/src/event-plugin.c \
src/libtraceevent/src/kbuffer-parse.c \
src/libtraceevent/src/parse-utils.c \
src/libtraceevent/src/parse-filter.c \
src/libtraceevent/src/trace-seq.c \
src/libtraceevent/src/tep_strerror.c \
src/libtracefs/src/tracefs-instance.c \
src/libtracefs/src/tracefs-utils.c \
src/trace-cmd/trace-read.cpp \
src/imgui/imgui_freetype.cpp \
src/gpuvis_i915_perfcounters.cpp
src/trace-cmd/trace-input.c \
src/trace-cmd/trace-hooks.c \
src/trace-cmd/trace-output.c \
src/trace-cmd/trace-compress.c \
src/trace-cmd/trace-msg.c \
src/trace-cmd/trace-filter.c \
src/trace-cmd/trace-compress-zstd.c \
src/trace-cmd/trace-compress-zlib.c \
src/trace-cmd/trace-util.c

ifeq ($(PROF), 1)
# To profile with google perftools:
Expand Down Expand Up @@ -207,6 +230,12 @@ $(ODIR)/src/libtraceevent/src/parse-utils.o: CFLAGS += -Wno-pedantic -Wno-implic
$(ODIR)/src/libtraceevent/src/event-parse-api.o: CFLAGS += -Wno-pedantic
$(ODIR)/src/imgui/imgui.o: CXXFLAGS += $(NO_STRINGOP_TRUNCATION)
$(ODIR)/src/trace-cmd/trace-read.o: CXXFLAGS += $(NO_CLOBBERED)
$(ODIR)/src/trace-cmd/trace-input.o: CFLAGS += -Wno-pedantic -Wno-pointer-arith -Wno-shadow -Wno-sign-compare
$(ODIR)/src/trace-cmd/trace-util.o: CFLAGS += -Wno-pedantic -Wno-old-style-declaration -Wno-sign-compare -Wno-suggest-attribute=format -D_GNU_SOURCE
$(ODIR)/src/trace-cmd/trace-hooks.o: CFLAGS += -Wno-pedantic
$(ODIR)/src/trace-cmd/trace-output.o: CFLAGS += -Wno-pedantic
$(ODIR)/src/libtracefs/src/tracefs-instance.o: CFLAGS += -Wno-pedantic
$(ODIR)/src/libtracefs/src/tracefs-utils.o: CFLAGS += -Wno-pedantic

$(ODIR)/%.o: %.c Makefile
$(VERBOSE_PREFIX)echo "---- $< ----";
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Embeds [DroidSans.ttf](http://www.google.com/fonts/specimen/Droid+Sans) font by

Uses [stb_textedit.h, stb_truetype.h, stb_rectpack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).

trace-cmd is [GNU GPL v2](https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git)
trace-cmd is [GNU GPL v2](https://www.trace-cmd.org)

miniz is MIT licensed: [miniz](https://github.com/richgel999/miniz)

Expand Down
2 changes: 1 addition & 1 deletion src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ void TraceEvents::init_sched_switch_event( trace_event_t &event )

// Seems that sched_switch event.pid is equal to the event prev_pid field.
// We're running with this in several bits of code in gpuvis_graph, so assert it's true.
assert( prev_pid == event.pid );
//$$$$ assert( prev_pid == event.pid );

// Look in the sched_switch next queue for an event that said we were starting up.
plocs = get_sched_switch_locs( prev_pid, TraceEvents::SCHED_SWITCH_NEXT );
Expand Down
129 changes: 129 additions & 0 deletions src/libtracefs/include/tracefs-local.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* SPDX-License-Identifier: LGPL-2.1 */
/*
* Copyright (C) 2019, VMware, Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
*
*/
#ifndef _TRACE_FS_LOCAL_H
#define _TRACE_FS_LOCAL_H

#include <pthread.h>

#define __hidden __attribute__((visibility ("hidden")))
#define __weak __attribute__((weak))

#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))

/* Will cause a division by zero warning if cond is true */
#define BUILD_BUG_ON(cond) \
do { if (!(1/!(cond))) { } } while (0)

#define HASH_BITS 10

struct tracefs_options_mask {
unsigned long long mask;
};

struct tracefs_instance {
struct tracefs_options_mask supported_opts;
struct tracefs_options_mask enabled_opts;
char *trace_dir;
char *name;
pthread_mutex_t lock;
int ref;
int flags;
int ftrace_filter_fd;
int ftrace_notrace_fd;
int ftrace_marker_fd;
int ftrace_marker_raw_fd;
bool pipe_keep_going;
bool iterate_keep_going;
};

extern pthread_mutex_t toplevel_lock;

static inline pthread_mutex_t *trace_get_lock(struct tracefs_instance *instance)
{
return instance ? &instance->lock : &toplevel_lock;
}

void trace_put_instance(struct tracefs_instance *instance);
int trace_get_instance(struct tracefs_instance *instance);

/* Can be overridden */
void tracefs_warning(const char *fmt, ...);

int str_read_file(const char *file, char **buffer, bool warn);
char *trace_append_file(const char *dir, const char *name);
char *trace_find_tracing_dir(bool debugfs);

#ifndef ACCESSPERMS
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
#endif

#ifndef ALLPERMS
#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
#endif

#ifndef DEFFILEMODE
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* 0666*/
#endif

struct tracefs_options_mask *
supported_opts_mask(struct tracefs_instance *instance);

struct tracefs_options_mask *
enabled_opts_mask(struct tracefs_instance *instance);

char **trace_list_create_empty(void);
int trace_list_pop(char **list);

char *append_string(char *str, const char *delim, const char *add);
int trace_test_state(int state);
bool trace_verify_event_field(struct tep_event *event,
const char *field_name,
const struct tep_format_field **ptr_field);
int trace_append_filter(char **filter, unsigned int *state,
unsigned int *open_parens,
struct tep_event *event,
enum tracefs_filter type,
const char *field_name,
enum tracefs_compare compare,
const char *val);

struct tracefs_synth *synth_init_from(struct tep_handle *tep,
const char *start_system,
const char *start_event);

#define HIST_COUNTER_TYPE (TRACEFS_HIST_KEY_MAX + 100)
int synth_add_start_field(struct tracefs_synth *synth,
const char *start_field,
const char *name,
enum tracefs_hist_key_type type);

/* Internal interface for ftrace dynamic events */

struct tracefs_dynevent {
char *trace_file;
char *prefix;
char *system;
char *event;
char *address;
char *format;
enum tracefs_dynevent_type type;
};

struct tracefs_dynevent *
dynevent_alloc(enum tracefs_dynevent_type type, const char *system,
const char *event, const char *address, const char *format);
int dynevent_get_count(unsigned int types, const char *system);

int trace_load_events(struct tep_handle *tep,
const char *tracing_dir, const char *system);
int trace_rescan_events(struct tep_handle *tep,
const char *tracing_dir, const char *system);
struct tep_event *get_tep_event(struct tep_handle *tep,
const char *system, const char *name);

unsigned int quick_hash(const char *str);

#endif /* _TRACE_FS_LOCAL_H */
Loading

0 comments on commit ea0bd3c

Please sign in to comment.