Skip to content

Big refactoring: rewrite core TreeNode mutable double-linked tree data structure to immutable single-linked persistent tree #1215

@nikitabobko

Description

@nikitabobko

TreeNode is a core data structure of AeroSpace and unfortunately it's mutable.

The proposal is to rewrite it to immutable single-linked persistent tree.

Motivation:

  1. Stability. The current logic for binding two TreeNode is fragile and sometimes leads to hard to debug crashes: AeroSpace crash when open Xcode windows #706
  2. Performance. Once we make AeroSpace multi-threaded to handle hanging apps (Delay/freeze when switching focus & workspace #131), instead of "drawing" the layout on main thread and sending requests to app-threads, it makes sense to pass the tree data structure to each app-thread so that it could draw its part of the tree, which effectively makes the drawing multi-threaded by number of apps. Multi-threading drawing will help to reduce threads context switching for cases when apps have several visible windows. Though the tree has to be traversed multiple times in multi-threaded drawing approach. Precise performance measurements needs to be done.
  3. It makes it possible to take snapshots of the tree on its every modification before windows start "dying out" when the screen is locked. It should help to fix this issue: Windows may randomly jump to the focused workspace #1216
  4. Features like aerospace undo become possible (though, it may be too far fetched, who would need such a feature?)

Related: #1257

Metadata

Metadata

Assignees

No one assigned

    Labels

    problemNeither a bug, nor a feature request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions