summaryrefslogtreecommitdiff
path: root/src/hist_view.h
blob: 165ab0ba09ae27f49516d25b61f852e2cfe01155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef WSAP_VTCORE_HIST_VIEW_H
#define WSAP_VTCORE_HIST_VIEW_H

#include "hist.h"

struct line_pos {
    uint64_t id;
    uint32_t seg;
};

struct view_anchor {
    uint64_t line_id;
    uint64_t cell;
    uint64_t base_cell;
    uint32_t seg;
    bool active;
};

struct hist_view {
    struct view_anchor anchor;

    /* Line ids map to circular slots. Tree sums use physical slot order. */
    uint64_t *fenwick;
    uint32_t *counts;
    uint64_t total_rows;
    uint64_t first_id, end_id;
    uint64_t epoch, head, tail, last_cells;
    int cols;
    uint32_t cap;
    int index_cols;
};

void wsap_vtcore_hist_view_free(struct hist_view *v);

/* Update the index during snapshot capture. Reads do not change it. */
bool wsap_vtcore_hist_view_sync(struct hist_view *v, const struct hist *h, int cols);
void wsap_vtcore_hist_view_refine(struct hist_view *v, struct hist *h, int cols, int rows);
uint64_t wsap_vtcore_hist_view_rows(const struct hist_view *v, const struct hist *h, int cols);
bool wsap_vtcore_hist_view_find_row(const struct hist_view *v, const struct hist *h, int row,
                        int cols, uint64_t *id, int *seg);

/* Read the offset from the anchor at the current width. */
int wsap_vtcore_hist_view_scroll_offset(const struct hist_view *v, const struct hist *h, int cols);
void wsap_vtcore_hist_view_scroll(struct hist_view *v, const struct hist *h, int cols,
                      struct line_pos screen_top, int lines);
void wsap_vtcore_hist_view_scroll_to(struct hist_view *v, const struct hist *h, int cols,
                         struct line_pos screen_top, int offset);

struct hist_view_pos {
    uint64_t id;
    int seg;
    int screen_y;
};

/* Clamp an evicted anchor. This does not update the index on the write path. */
void wsap_vtcore_hist_view_note_push(struct hist_view *v, const struct hist *h, int cols);
void wsap_vtcore_hist_view_rewrap(struct hist_view *v, const struct hist *h, int cols);

bool wsap_vtcore_hist_view_row_pos(const struct hist_view *v, const struct hist *h, int cols,
                       int screen_rows, struct line_pos screen_top, int y,
                       struct hist_view_pos *pos);

#endif