Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this code very faster #539

Open
wants to merge 73 commits into
base: master
Choose a base branch
from

Conversation

mProjectsCode
Copy link
Contributor

🦀
(feel free to change the name of this PR)

@mProjectsCode
Copy link
Contributor Author

mProjectsCode commented Apr 27, 2024

TODO list:

  • make edge builder build the rust data directly
  • relevant settings get passed to rust
  • implement all features for mermaid code blocks
  • implement all features for tree view
  • fix all of the other views
  • get incremental graph rebuilds on vault events working => Separate PR
  • re-implement the transitive rule preview in the settings
  • fix the thread command
    • The target note needs to be created first, before trying to add the new edge to the graph
  • update the settings types so that the old types can be removed => Separate PR
    • e.g. implied_rule.chain uses a BCAttribute[], but only ever needs to be a string[] in practice
  • remove old commented out code
  • revive the markmap code block
  • improve graph updates via debouncing and aggregating into one batch update => Separate PR

Copy link
Owner

@SkepticMystic SkepticMystic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far. I'm gonna try review frequently to keep the diff size small

src/components/codeblocks/CodeblockMermaid.svelte Outdated Show resolved Hide resolved
wasm/src/graph.rs Show resolved Hide resolved
src/commands/list_index/index.ts Outdated Show resolved Hide resolved
src/components/EdgeLink.svelte Outdated Show resolved Hide resolved
src/components/EdgeLink.svelte Show resolved Hide resolved
src/components/NestedEdgeList.svelte Outdated Show resolved Hide resolved
Copy link
Owner

@SkepticMystic SkepticMystic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, continues to get closer :)

src/components/EdgeLink.svelte Outdated Show resolved Hide resolved
wasm/src/graph.rs Outdated Show resolved Hide resolved
wasm/src/graph.rs Outdated Show resolved Hide resolved
wasm/src/graph.rs Outdated Show resolved Hide resolved
Copy link
Owner

@SkepticMystic SkepticMystic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is mcuh easier to understand now

src/components/page_views/TrailView.svelte Outdated Show resolved Hide resolved
src/components/side_views/Matrix.svelte Outdated Show resolved Hide resolved
src/components/side_views/TreeView.svelte Outdated Show resolved Hide resolved
wasm/src/graph_traversal.rs Outdated Show resolved Hide resolved
wasm/src/graph_traversal.rs Outdated Show resolved Hide resolved
@mProjectsCode
Copy link
Contributor Author

Some preliminary performance metrics. (Take with a grain of salt, as with all benchmarks.)
Tested with 2564 notes in a tree shape. Each note has 1 to 3 explicit up frontmatter links. The tree is cut off at depth 10.
Transitive rules:

[up] <- down
[down] <- up
[same] <- same
[uncle] <- nephew
[nephew] <- uncle
[up, down] -> same
[up, same] -> uncle

This fork:

  • Initial Graph: ~4ms
  • Implied Edges: ~2.5ms
  • Total: ~18ms

Current Master (4.2.27) after running a few times to get JIT advantages:

  • Implied Edges: ~70ms
  • Total: ~85ms

This fork is about 4x faster regarding total time and about 25x faster in building implied edges.

Copy link
Owner

@SkepticMystic SkepticMystic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looking good

@mProjectsCode
Copy link
Contributor Author

Did some optimizations:

  1. removed dyn in hot paths and replaced it with enums
  2. replaced String with Rc<str> since we have lots of the same small strings, we can use Rc, which only clones the pointer and not the string.

@mProjectsCode
Copy link
Contributor Author

I limited the tree view and trail view to depth 5 for now. The graph engine can easily handle more, but the rendering is too slow. There should be an indicator that a cut-off happened though.

@mProjectsCode
Copy link
Contributor Author

The total graph rebuilding time is now at ~15ms for a tree structure vault with 2.5k files.

@mProjectsCode
Copy link
Contributor Author

Some more progress:

  1. removed a lot of potential crash points in the Rust part, now they will throw a JS error
  2. updated to svelte 5
  3. some further minor optimizations

@mProjectsCode mProjectsCode marked this pull request as ready for review January 12, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants