Closed vladmandic closed 3 months ago
Really cool to finally have someone collaborating on the code!
Instead of copy-pasting time counter everywhere, do a function decorator
function test(count) {
for (const x of Array(count).keys()) {
console.log(x, String.fromCharCode('A'.charCodeAt(0) + x));
}
return true;
}
function functionLogTime( func ) { function newFunc() { const t0 = performance.now(); const returnValue = func(...arguments); const t1 = performance.now();
console.log(`Done ${func.name}`, Math.round(t1 - t0) / 1000);
return returnValue;
}
return newFunc;
}
test = functionLogTime(test); test(10);
- Refactor flags
```js
//= ====================== READY STATES =======================
function functionWaitForFlag(checkFlag) {
return async function () {
return new Promise((resolve) => {
const check = () => checkFlag() ? resolve() : setTimeout(check);
check();
});
}
}
let uiFlagInitialized = false;
let uiFlagPortalInitialized = false;
waitForUiReady = functionWaitForFlag(() => uiFlagInitialized);
waitForUiPortal = functionWaitForFlag(() => uiFlagPortalInitialized);
2024-04-06 10:06:31.568 UI removeStyleSheets 33
2024-04-06 10:06:32.250 UI removeElements 18396/18531
2024-04-06 10:06:40.522 UI loadTemplates 8.269
2024-04-06 10:06:40.953 UI loadPortals 0.363
2024-04-06 10:06:41.276 UI extraTweaks 0.2
2024-04-06 10:06:41.278 UI ready 9.722
2024-04-06 10:06:43.980 removeSplash
2024-04-06 10:06:43.983 startupTime 33.791
2024-04-06 10:06:44.440 initIndexDB 0
2024-04-06 10:08:06.925 UI removeStyleSheets 33
2024-04-06 10:08:07.042 UI removeElements 23550/23684
2024-04-06 10:08:11.074 UI loadTemplates 4.031
2024-04-06 10:08:11.794 UI loadPortals 0.638
2024-04-06 10:08:12.095 UI extraTweaks 0.24
2024-04-06 10:08:12.095 UI ready 5.186
2024-04-06 10:08:12.673 removeSplash
2024-04-06 10:08:12.674 startupTime 13.329
2024-04-06 10:08:13.531 initIndexDB 369
What are the added core sdnext features ?
massive changes overall, but at the end not all that much that impacts uiux - onUiReady
is a new event callback and log()
function is updated to work with or without modernui.
I am not sure about renaming the file modernUI.js, won't we loose file history ?
true. you can ignore the pr and do the comit yourself.
modernui.js
to sdnext_uiux_core.js
and commit without modernui.js
sdnext_uiux_core.js
to modernui.js
What is the point of eslint formatting ? (it is really ugly)
formatting is always an opinionated thing - those are rules i've been using for a long time. but at the end, formatting is a sideeffect, more importantly eslint is there primarily as linter not as formatter. and it did catch some items that needed to be addressed plus some bad items (incorrect indent, undeclared variables, redeclared variables, blank spaces, mixed usage of tabs and spaces, etc.), although nothing really broken or horrible.
So now setupLogger is never called ? I can remove it, but we need to fix splash (see later) The splashScreen is hidden under gradio-app before all ui is loaded leaving a gray screen
correct. and yes, you can fix the splash so its never created.
Refactor flags
variable is not defined in global context unless defined on window level. function is. so main sdnext startup.js cannot use them as you wrote. but if you prefer your way, fine by me, just be aware that you need to make changes to startup.js as well.
It seems like logPrettyPrint is not using the same colors as prior.
you can reintroduce some colors, its just that it was linked to some really strange string patterns. i tried to make it match strings that are actually used in logging.
I think new favicon is way better than the old one, until we change the old one I want to keep this as it's fitting modern theme
i like the new favicon as well, but i really don't want to have different icon only when uiux is running. nothing preventing me from using new icon from right now - if you agree, i'll add it to core today.
Instead of copy-pasting time counter everywhere, do a function decorator
i know that, but while doing dev work, i made faaaar more timers within functions (t0, t1, t2, t3, t4) so i can trace each op. at the end i removed all interim ones that were below 0.1sec so what's left is what you see. and decorator has one sideeffect that it makes breakpoints/errorhandling/tracing much more difficult since it will appear in the decorator function instead in the desired function. all ok, just i prefer simpler approach while still in active dev.
Profiling
oh, wow, recursive fetch is really slow on your system. once this is merged, we can look at optimizing it - i have some ideas on how to parallelize at least a bit.
true. you can ignore the pr and do the comit yourself.
1. copy & paste content of `modernui.js` to `sdnext_uiux_core.js` and commit without `modernui.js` 2. rename `sdnext_uiux_core.js` to `modernui.js`
Will do
formatting is always an opinionated thing - those are rules i've been using for a long time. but at the end, formatting is a sideeffect, more importantly eslint is there primarily as linter not as formatter. and it did catch some items that needed to be addressed plus some bad items (incorrect indent, undeclared variables, redeclared variables, blank spaces, mixed usage of tabs and spaces, etc.), although nothing really broken or horrible.
How do I use it ?
correct. and yes, you can fix the splash so its never created.
It's already not created, but it's a z-index issue I'll fix
i like the new favicon as well, but i really don't want to have different icon only when uiux is running. nothing preventing me from using new icon from right now - if you agree, i'll add it to core today.
Go for it
oh, wow, recursive fetch is really slow on your system. once this is merged, we can look at optimizing it - i have some ideas on how to parallelize at least a bit.
What do you call recursive fetch ? Anyway we can optimize, but I think priority is fixing existing bugs
How do I use it ?
copy .eslintrc.json
and package.json
from sdnext root and do npm install
- then you can just run eslint
sdnext is configured not to lint anything in extensions, but it will automatically check anything in core
so once we integrate uiux from extension into core, its best to be ready
Go for it
done.
What do you call recursive fetch ?
it loads initial template, then parses it then loads whatever is referenced there, etc.
Anyway we can optimize, but I think priority is fixing existing bugs
absolutely. none of the remaining performance items are critical.
overview
sdnext_uiux.js
i've created a new file
modernUI.js
take a look and if you're ok with it, delete
sdnext_uiux.js
(you cannot run with both files present since they will conflict)
changes
this caused massive changes, but needed to be done once
this also removed a lot of blank lines, but feel free to use them in the future,
just make sure there are no spaces in blank lines
it should be included in the javascript folder directly
now logger includes full sdnext startup sequence, not just from uiux
also, uiux should not override console.log
plus cleaned-up logprettyprint a bit
if we want to change favicon, we can do that in main app
profiling
anyhow, startup time of uiux is now below 1sec (and it used to be >4sec!) which is acceptable
90% of time is in:
i think this can be optimized a bit, but not critical
yeah, its not as much of a problem as i thought
really not sure why is this one taking so long, but its not a big deal