EPICLab / synectic

Cards-based IDE for research into context-aware, heuristic problem-solving development tools.
https://epiclab.github.io/synectic/
MIT License
5 stars 0 forks source link

Multithreading Redux Actions #1082

Closed nelsonni closed 1 year ago

nelsonni commented 1 year ago

Describe the bug Loading large files into the Redux store results in significant delays which trigger the Redux Serializability Middleware threshold of 32ms per event (with most events requiring 30-40ms, but occasionally spiking above 60ms). These events correspond to an unresponsive UI and sluggish load times.

For larger projects (with lots of files), these warnings will be triggered every time the FSCache subsystem attempts to update the Redux store state. An example warning message (typically one of 100+ such messages that appear in the DevTools console logs when loading a large project such as EPICLab/ant-design):

SerializableStateInvariantMiddleware took 40ms, which is more than the warning threshold of 32ms. 
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
It is disabled in production builds, so you don't need to worry about that. 
    at FileComponent (webpack-internal:///./src/components/Explorer/FileComponent.tsx:47:26)
    at ul
    at TreeView (webpack-internal:///./node_modules/@material-ui/lab/esm/TreeView/TreeView.js:57:24)
    at WithStyles (webpack-internal:///./node_modules/@material-ui/styles/esm/withStyles/withStyles.js:64:31)
    at div
    at Explorer (webpack-internal:///./src/components/Explorer/Explorer.tsx:16:49)
    at Content (webpack-internal:///./src/components/Card/ContentFront.tsx:15:18)
    at div
    at ContentFront
    at Transition (webpack-internal:///./node_modules/react-transition-group/esm/Transition.js:132:30)
    at CSSTransition (webpack-internal:///./node_modules/react-transition-group/esm/CSSTransition.js:119:35)
    at div
    at CardComponent (webpack-internal:///./src/components/Card/CardComponent.tsx:67:56)
    at div
    at Canvas (webpack-internal:///./src/components/Canvas/Canvas.tsx:59:51)
    at FSCacheProvider (webpack-internal:///./src/store/cache/FSCache.tsx:55:28)
    at DndProvider (webpack-internal:///./node_modules/react-dnd/dist/cjs/core/DndProvider.js:40:11)
    at PersistGate (webpack-internal:///./node_modules/redux-persist/es/integration/react.js:38:5)
    at Provider (webpack-internal:///./node_modules/react-redux/es/components/Provider.js:15:3)
    at App (webpack-internal:///./src/app.tsx:43:27)

To Reproduce Steps to reproduce the behavior:

  1. Launch Synectic
  2. Go to FileOpen...
  3. Select the root directory of a project containing large files
  4. See warnings in the Developer Tools console

Expected behavior Loading files in the background and presenting necessary details in the UI as the user opens files, directories, and branches in the different cards displayed on the canvas.

Screenshots image

Versions (please complete the following information):

Additional context Attempts to load EPICLab/ant-design result in the following console log warnings: localhost-1672852410238.log

nelsonni commented 1 year ago

Attempts to unload some of the CPU intensive calls (i.e. fetchRepo, fetchBranches, updateVersionedMetafile) to background threads inevitably result in a catch-22 situation. For example, in order to use Web Workers in a Node.js environment using webpack, you must use ESM per webpack docs:

Similar syntax is supported in Node.js (>= 12.17.0):

import { Worker } from 'worker_threads';

new Worker(new URL('./worker.js', import.meta.url));

Note that this is only available in ESM. Worker in CommonJS syntax is not supported by either webpack or Node.js.

But attempts to run this code in Electron result in the following: image

This is because Electron currently only supports CommonJS modules. However, there are some potential future fixes that might introduce ESM support in Electron in the future:

nelsonni commented 1 year ago

Other multi-threading options include:

nelsonni commented 1 year ago

Resolved in Synectic v4.0.0.