Invoke Async Refactor #53
Merged
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.
Replaced Blazor Interop & Moved To Custom Communication
I've stripped away from Blazor their interop control over the library. No more double serializing and double deserializing. Instead "magicDbMethods.js" was introduced to dynamically call methods and replicate effectively what the modern Blazor Invoke Async already does. This removes the double unnecessary serializations.
Additionally I've moved everything to a streamed async communication to remove all C# to JS limits (aka no 16 MB limit on WASM nor 32 KB limit on server rendered / aka signalR). This introduces slight latency, but uncapped data transfer. The improvements in performance though showed in my results that the increase in latency is vastly outweighed by the removal of double deserialization, making this a net positive all around.
The only down side to this new version memory allocations that occurs at fractional seconds of memory processing and translation. This would only be an issue when data being transferred is somewhere around 70 MB to 100 MB (not fully sure yet). There's a few ideas I'm considering to remedy this. But the issue is inherent to Blazor itself and the fact it does NOT support JSON parse streaming, which is kind of exactly what the doctor ordered here. Without proper Json Parse streaming, options are limited. I will mull over this concept for a bit, but for now we're not just drastically faster, but bandwidth increased by ~4.4X minimum on Blazor WASM and 2,250X higher on SignalR server rendered blazor.
JS Where Massive Improvement
The "where" method in JS has gotten a large boost in performance. instead of utilizing getTable and grabbing large amounts of items to be processed in memory. Now properly utilizing cursors, we properly translate the where statement to iterative row lookups. Making performance both faster and compressing memory use drastically.
Equal,GreaterThan,LessThan, etc.)jsonQuerieswith multiple conditions)orderBy,orderByDescending)skip,take,takeLast).and()).each())Promise.all()for speed)Review Notes
I'm going to manually just push this to Main later. Was just using this PR as documentation of changes and leaving it hanging for a day or 2 while I think over the changes. I'm also in the midst of altering the predicate builder system as well to be vastly more performant as well. Unsure if that'll be in this PR or another. This will also open the doors for us to create capabilities of more complex query capabilities with Joins and more. Well more like helpful illusions because IndexDB can't do that by default, but these are all very helpful new additions.
I'm also unsure if this PR will have this update or not, but I'm also trying to remove the "Execute" command entirely. It's unnecessary and should work like LINQ to SQL in which you can "ToList()" to get a list or you can work with the IEnumerable with deferred execution, or use that to make individual calls in a loop or anything else.
Though @yueyinqiu I don't see any where statement unit tests. We may want to make a to do list together at some point of unit tests we want to create. Because I just want to make sure I'm not making changes that breaks current functionality.
Feature Requests
Additional fixes
People In IndexedDB!
Complex Query Capabilities!
Within the table, "Id" is the primary key, "Name" is indexed, and "Age" is not an index at all, but utilizes cursors to query.
The following query is executed against IndexedDB using a LINQ-style syntax:
Here is your Markdown-formatted content for GitHub:
People In IndexedDB!
Complex Query Capabilities!
The following query is executed against IndexedDB using a LINQ-style syntax:
Results
The query returned the following matching people:
How the Logic Works
This query correctly filters and processes the dataset due to proper query translation and ordering:
Filtering Logic:
Name.StartsWith("c")→ Matches Cathy.Name.StartsWith("l")→ Matches Luna.Name.StartsWith("j") && Age > 35→ Matches Jon and Jack (but not Jerry, because he is 35, not greater than 35).Ordering & Skipping:
IDin ascending order.Final Matching Set:
StartsWith("c")).StartsWith("l")).StartsWith("j")andAge > 35).StartsWith("j")andAge > 35).This properly shows that we are now querying accordingly in a complex query situation.
Big Feature Change
Due to this rework and repair. I implemented Cursors when items are not indexed. This means that you can iteratively look through rows and properly query even if it's not an index!