-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Epic rewrite #378
Open
nazmulidris
wants to merge
29
commits into
main
Choose a base branch
from
epic-rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Epic rewrite #378
+23,980
−13,209
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create 2 new crates: - script - log - support UnicodeString for output - update all calls to tracing::*() to work seamlessly with CustomEventFormatter across the entire r3bl codebase (especially r3bl_tui examples) - add of the `options: impl Into<TracingConfig>` pattern for configuring the log functionality. this is ergonomic for simple cases (for the caller) and provides sophisticated configuration possibilities due to its composability. Reorganize all the existing crates as well, to ensure that known duplicated functions are removed. Add new glyphs that are unicode character based, not emojis, so that the fg, bg color and attributes are applied in output. Emojis come with their own colors, so the fg and bg colors don't get applied. Use Vec::with_capacity wherever possible to prevent having reallocations which are expensive, and create a global size limit for the all the r3bl crates.
…ce tuning - Data oriented design: https://youtu.be/WwkuAqObplU?si=5JPiDCfAG4YQxlhG - Memory alloc: https://youtu.be/pJ-FRRB5E84?si=EGD_Tge1ApGRkT6n&t=1831 - Scalarize/flatten: https://youtu.be/Dhn-JgZaBWo?si=oFiWnwKEhfJFxZCL Refactor ch_unit.rs: - Remove `ch!` and replace it easier to understand functions that are easier to compose, and produce better compiler errors. Change the memory usage of the codebase: - Preallocate as much as possible. - Allocate on the stack when possible. - Reduce the size of fields if they don't need to store large `usize` values. Update telemetry_global_static to provide MAX FPS Implement RingBuffer and RateLimiter Add support for `$TERM_PROGRAM` equals `vscode` to enable truecolor Add TimeDuration struct to format Duration in a performant and human readable way. No memory is allocated in the Display trait implementation (the function that renders `{}`). Update all Cargo.toml to Rust edition 2024 Remove `static_global_data.rs` module. Telemetry is now handled via the `Telemetry` struct, and `RateLimiter` and `RingBuffer`. Add rendering hints to Telemetry along with the telemetry_record! macro to make the telemetry measurement ergonomic and self documenting Clean up log output to use tracing::debug!, etc. correctly with message = {message}, etc.
[ At the start ... ] This is the 2 week long refactor that is showing performance regression over the previous commit! excluding the following: - tui/md_parser/convert_to_plain_text.rs - tui/syntax_highlighting/intermediate_types.rs - tui/syntax_highlighting/md_parser_syn_hi/md_parser_syn_hi_impl.rs The files in this commit had to be rolled back as part of the changes made in the last commit were breaking all the tui tests, especially around MD parsing. These files still need the memory optimization work: - stack vs heap app - use write! instead of format! [ And then ... ] This commit brings the performance back up to previous commit with SHA: 5603296 The slow down, as far as I can tell, from running different commits side by side, is that the computation of the UnicodeString proved to be quite expensive to do every time. So it is beneficial to memoize this! Running the code with flamegraph profiling didn't really show anything useful related to this problem. Apply heap allocation techniques to the code in the following modules to boost performance and keep it stable (steady): - [x] formatter.rs - [x] editor_engine.rs - [x] convert_to_plain_text.rs - [x] intermediate_types.rs - [x] md_parser_syn_hi_impl.rs
e091ab3
to
8372ca9
Compare
Caret position can be of two kinds: - Raw - Scroll adjusted Make this explicity using the type system and provide conversions between the two. Introduce new concrete types for: - Pos - row - col - Dim - width - height - Use them in the codebase instead of ChUnit. - Use ChUnit as the "inner" type of these new concrete types.
8372ca9
to
c60209f
Compare
7baa9d6
to
688a641
Compare
688a641
to
e7622cd
Compare
1ec05ac
to
ef65a6d
Compare
- Reorganize & create new modules for engine and buffer - Extract more modules that are distinct semantically - Remove empty structs used as namespace, and replace with modules - Remove Remove needless -> Option<()> statements
ef65a6d
to
99120f6
Compare
Properly bifurcate public and internal API using mod.rs
dd98237
to
04ea76d
Compare
- Clean up log messages - Clean up imports - Add docs - Add window size display when demo starts
- .code-search files are to keep track of work that is pending - scratch.rs is a file with snippets that are useful
6fb3ca5
to
d9a8ee1
Compare
There was a bug in the code dating back to when this function was first written. This bug didn't really affect anything. However it got exposed when the conversion to "newtype" pattern was introduced and all the ChUnit types got replaced with Pos, Dim, Width, Height, etc. Make variable names shorter, so that they don't have the "intended use in the absence of concrete types" backed into the their extremely long and unreadable names. This is all thanks to the work related to the "newtype" pattern!
0f65d0a
to
f45f90c
Compare
c800be4
to
fdbd030
Compare
Fix bug in main event loop which was preventing the app from handling resize events. This error was introduced in a previous refactor where the resize event gets consumed by the main event loop, after it records telemetry about it; instead of then also giving it to the app to handle or process.
fdbd030
to
c93aad3
Compare
Extract the inner type as EditorBufferMut. Provide two new types: 1. When validation is needed after mutations, using Drop. 2. When no validation needs to be performed (no Drop impl).
After fixing the newly introduced bug where resize events were no longer passed into the app by main event loop, add missing tests to ensure that the code works properly. Update diagrams using nice unicode drawing symbols. Unicode glyphs links (for the ASCII diagrams): - https://symbl.cc/en/unicode/blocks/box-drawing/ - https://symbl.cc/en/unicode/blocks/arrows/ - https://symbl.cc/en/collections/brackets/
537344b
to
29c374f
Compare
- Remove redundant type conversions in this module. - Use `fn foo(arg: into Impl<Struct>)` to make functions more ergonomic and reusable. - Clean up Rust doc comments.
29c374f
to
81a539e
Compare
This is more disambiguation by using proper types (now that they exist) by favoring more specific types over more generalized types in order to remove the need for documentation or overly long variable names (that describe the intent, which is now captured in the type system and can be checked by the compiler). SelectionRange now only works with CaretScrAdj types, so there's no way to pass a CaretRaw into the thing. And there's only one way to construct it. And it removes the RowIndex as part of construction (by clobbering it with an "impossible" value, rendering it clearly unusable and also looking strange when debugging, which is the intent). Clean up the dummy view port use case in buffer_selection_support.rs so that it no longer passes a 0x0 viewport when it doesn't have one. And instead passes some "impossible" value, rendering it clearly unusable and also looking strange when debugging, which is the intent).
Introduce a 1 sec timeout that will simply skip the test if github API is taking too long to run. This prevents a github slowdown or outage disrupting running all tests.
This struct should not have been in core to begin with. Thanks to the recent rewrite of the entire crate using "newtype" pattern that favors specific types over generalized ones, it became clear where this struct should belong. It wasn't clear before, with generalized type, which is why it was placed beside UnicodeString in core crate, rather than beside buffer_selection_support.rs in tui/editor/editor_buffer/ in tui crate.
0c33b51
to
9ef8cf4
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Started with
Also ended up doing
smallvec
andsmallstr
UnicodeString
impl andUnicodeStringSegment
ChUnit
to strongly typed units for height, width, row, col, dim, and pos.Issues closed