perf(wave1): reduce Config caps, reorder Client/Monitor for cache
Wave 1 changes: - Reduce CFG_MAX_KEYBINDS 256→128, CFG_MAX_STRLEN 256→64, CFG_MAX_ARGS 16→8 → saves ~2.5 MB BSS from Config struct - Add truncation warnings to config_load when keybind/button/scroll limit reached - Reorder Client struct: HOT fields (type, mon, tags, floating flags, geom) in first cache line, COLD fields (wl_listeners) at end — saves cache misses in arrange() - Reorder LayerSurface struct similarly - Split Monitor into Monitor/MonitorCold: hot fields (~120B) stay inline, cold layout state lazily allocated on first dwindle/master use - All cold-field accesses through m->cold-> indirection - cleanupmon frees m->cold - Zero-warning build with clang -Werror -Wpedantic
This commit is contained in:
+26
-14
@@ -20,23 +20,36 @@ struct wlr_scene_shadow;
|
||||
enum { XDGShell, LayerShell, X11 };
|
||||
|
||||
typedef struct Client {
|
||||
/* Must keep this field first */
|
||||
unsigned int type; /* XDGShell or X11* */
|
||||
/* Must keep this field first — union-cast discriminant */
|
||||
unsigned int type; /* XDGShell or X11 */
|
||||
|
||||
/* HOT — accessed every frame / arrange / focus / resize */
|
||||
Monitor *mon;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border_bg; /* single border rect with clipped content hole */
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wl_list link;
|
||||
struct wl_list flink;
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
int isurgent;
|
||||
int isfullscreen;
|
||||
int isscratchpad;
|
||||
struct wlr_box geom; /* layout-relative, includes border */
|
||||
struct wlr_box prev; /* layout-relative, includes border */
|
||||
struct wlr_box bounds; /* only width and height are used */
|
||||
unsigned int bw;
|
||||
int corner_radius;
|
||||
struct wlr_scene_shadow *shadow;
|
||||
|
||||
/* WARM — accessed less frequently */
|
||||
struct wl_list link;
|
||||
struct wl_list flink;
|
||||
union {
|
||||
struct wlr_xdg_surface *xdg;
|
||||
struct wlr_xwayland_surface *xwayland;
|
||||
} surface;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border_bg; /* single border rect with clipped content hole */
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||
|
||||
/* COLD — wl_listeners (set up once, rarely touched after) */
|
||||
struct wl_listener commit;
|
||||
struct wl_listener map;
|
||||
struct wl_listener maximize;
|
||||
@@ -53,26 +66,25 @@ typedef struct Client {
|
||||
struct wl_listener configure;
|
||||
struct wl_listener set_hints;
|
||||
#endif
|
||||
unsigned int bw;
|
||||
int corner_radius;
|
||||
struct wlr_scene_shadow *shadow;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen, isscratchpad;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
/* Must keep this field first — union-cast discriminant */
|
||||
unsigned int type; /* LayerShell */
|
||||
|
||||
/* HOT */
|
||||
Monitor *mon;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_tree *popups;
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer;
|
||||
struct wl_list link;
|
||||
int mapped;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
|
||||
/* WARM */
|
||||
struct wl_list link;
|
||||
|
||||
/* COLD — wl_listeners */
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener surface_commit;
|
||||
|
||||
+15
-10
@@ -21,6 +21,20 @@ typedef struct {
|
||||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
/* Cold state — accessed only on layout changes, not every frame.
|
||||
* Allocated lazily on first dwindle/master layout use. */
|
||||
typedef struct MonitorCold {
|
||||
const Layout *lt[TAGCOUNT][2];
|
||||
unsigned int sellt[TAGCOUNT];
|
||||
float mfact;
|
||||
int nmaster;
|
||||
char ltsymbol[TAGCOUNT][16];
|
||||
DwindleNode *dwindle_root[TAGCOUNT];
|
||||
struct Client *dwindle_focus[TAGCOUNT];
|
||||
struct Client *master_master[TAGCOUNT];
|
||||
int master_side[TAGCOUNT];
|
||||
} MonitorCold;
|
||||
|
||||
struct Monitor {
|
||||
struct wl_list link;
|
||||
struct wlr_output *wlr_output;
|
||||
@@ -34,21 +48,12 @@ struct Monitor {
|
||||
struct wlr_box m; /* monitor area, layout-relative */
|
||||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface.link */
|
||||
const Layout *lt[TAGCOUNT][2]; /* per-tag layout slots */
|
||||
struct MonitorCold *cold; /* lazy-allocated layout state */
|
||||
int gaps;
|
||||
unsigned int seltags;
|
||||
struct wlr_ext_workspace_group_handle_v1 *ext_group;
|
||||
unsigned int sellt[TAGCOUNT]; /* per-tag layout toggle index */
|
||||
uint32_t tagset[2];
|
||||
float mfact;
|
||||
int nmaster;
|
||||
char ltsymbol[TAGCOUNT][16]; /* per-tag layout symbol */
|
||||
int asleep;
|
||||
DwindleNode *dwindle_root[TAGCOUNT]; /* one tree per tag */
|
||||
struct Client *dwindle_focus[TAGCOUNT]; /* insertion anchor, one per tag */
|
||||
/* master/stack layout state */
|
||||
struct Client *master_master[TAGCOUNT]; /* the master client (NULL if none) */
|
||||
int master_side[TAGCOUNT]; /* 0 = master on left, 1 = master on right */
|
||||
int scratchpad_visible; /* whether scratchpad is shown */
|
||||
struct Client *scratchpad_prev_focus; /* client focused before scratchpad opened */
|
||||
struct Client *scratchpad_current; /* currently visible scratchpad client */
|
||||
|
||||
Reference in New Issue
Block a user