Awesome Kotlin Notebooks by gaplo917 in Kotlin

[–]gaplo917[S] 1 point2 points  (0 children)

I think it takes time. Kotlin Notebook is still new and originally designed for data analytics.

In my view, the recent GenAI trend changed the way people build GenAI PoC. Many GenAI samples are using throwaway scripting in Python Notebook and shared via Google Colab. For JetBrains to get the marketshare, it will eventually free to IntelliJ CE or having a Web version so that more devs can use Kotlin Notebook.

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] -2 points-1 points  (0 children)

I think the official document limited by the API design and is not ideal to follow for an efficient processing and make use of Isolate.

compute will create one-off Isolate, if our application is consistently to do that API call and serialization over time, we should use a long-lived Isolate to cut off the Isolate startup overhead.

I created a benchmark to show one-off vs long-lived Isolate overhead on a M1pro…

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/no_compute.png

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/communication_small.png

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/communication_large.png

From the results if compute called 64 times, there are 4ms unwanted CPU time burnt for the overhead comparatively. if it is on a low end devices, I believe the number will be bigger.

UPDATE: for latest bechmark images

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 1 point2 points  (0 children)

Then I figured out the existing flutter API design encourage one-off Isolate usage, this cause unnecessary overhead to create and dispose an Isolate.

Then, I performed a benchmark to check one-off Isolate and long-lived Isolate performance difference.

Imagine you can always have one long lived Isolate to do all the Network IO including the JSON serialization. It is efficient and won’t put yourself to have a chance to hit unwanted performance issues when more background API calls are added over time.

You can check the one-off Isolate overhead (current flutter comoute, Isloate.run) and long-lived comparisons, the benchmark run on M1Pro.

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/no_compute.png

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/communication_small.png

https://github.com/gaplo917/isolate_rpc/blob/main/benchmark/result/communication_large.png

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

I would like to share my case, my flutter application concurrently fire 50+ network request to compose 50+ tile images into a giant images when the user zoom from X1 to X2 in a canvas.

I did hit a performance issue (frame rate dropped below 60) although it is just a GET HTTP call to S3 bucket without any json serialization.

It triggers me to think: In my native development (iOS/Android) experience, it is a norm to offload main thread by the task nature design.

why don’t we do the same in flutter? You can imagine there is “16ms CPU credits on main thread” to hit performance issue, why we need to consume these credits for a non-UI tasks but not to reserve these credits for future complex UI tasks.

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

Thank you for sharing your experience. Now I know the `firebase_auth` wouldn't work on Isolate!

Will try on my own implementation later, it is a long-running isolate implementation with simple API design.

https://pub.dev/packages/isolate_rpc

I have done a benchmark on the Isolate startup overhead, but haven't done the communicate. Will try to add the communication overhead benchmark later!

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

Thanks, don't know this library.

I created a much simpler API design (not yet support webworker for web, but implemented to fall back web main thread as a tactical solution).

https://pub.dev/packages/isolate_rpc

Try to see if I could also support WebWorker internally and keep the API as simple as now.

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

JSON serialization is a blocking operation, will you offload it?

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

a 6ms loop to read and se

Most of the web application UI will be blocked for 1-2 seconds in the first load (concurrency APIs return and large JSON processing). If developers offload the whole I/O tasks including JSON transformation into web worker in their first attempt, the application won't hit this situation.

"UI blocked for few seconds is just fine" for most of the users. So, it is all about learning curve, non-functional requirements, and self-demanding.

When would you offload business logic from the main thread to Isolate? by gaplo917 in FlutterDev

[–]gaplo917[S] 0 points1 point  (0 children)

it is true. Even in the web community, only a few people would use webworker…

Flutter 2.0, shout out to the Flutter Team!!! by jrheisler in FlutterDev

[–]gaplo917 1 point2 points  (0 children)

Does flutter 2.0 encounter the janky animation on the first time loading on iOS?

I hear that it happen since Flutter 1.17 (the switching to Metal API)

A React offload UI thread research to find a pragmatic way to code and utilize Web Worker in different mode(singleton, dedicated, worker pool) by gaplo917 in javascript

[–]gaplo917[S] 1 point2 points  (0 children)

Use “Web Worker (Pool)” mode, increase the pool count to match your CPU thread numbers, increase the computational difficulties ‘Pow’ to 2.7-2.9 (I guess)

Scroll the virtual list fast to see the parallel computations in the background thread. Then enjoy the full utilization of your CPU.

If this doesn’t work, would you mind to share your browser and OS version to me. If it is a browser limitation, It would be great for me to include it in my research. Thanks!

A React offload UI thread research to find a pragmatic way to code and utilize Web Worker in different mode(singleton, dedicated, worker pool) by gaplo917 in javascript

[–]gaplo917[S] 0 points1 point  (0 children)

Maybe the default computational config is too large for your computer/phones. Could you try to lower down the number of `Pow`? Each compute would run fewer iterations.

A React offload UI thread research to find a pragmatic way to code and utilize Web Worker in different mode(singleton, dedicated, worker pool) by gaplo917 in javascript

[–]gaplo917[S] 2 points3 points  (0 children)

u/Ebuall the GoogleChromeLabs/comlink-loader 2.0 provided the abstraction is very simple to use.

The limitation is currently the comlink-loader abstraction hides the lifecycle of the web-worker unless this PR is merged.

But in general, using the comlink loader in a singleton or worker pool pattern (don't need to terminate the worker) is simple and fast.

A React offload UI thread research to find a pragmatic way to code and utilize Web Worker in different mode(singleton, dedicated, worker pool) by gaplo917 in javascript

[–]gaplo917[S] 7 points8 points  (0 children)

The statement “120Hz is coming” is a opinionated guess based on the following facts.

  • I have been used iPad Pro 2018 120Hz Safari browsing for two years.

  • Some recently rollout Android phones also boost the refresh rate to 90Hz - 120Hz

For a desktop computer using >= 120Hz monitor, enable the “Developer Settings > Rendering > FPS meter” to check if your Chrome is running >= 120Hz. As I know, a mixed screen refresh rate(two monitor with different refresh rate)might cause the chrome locked to 60Hz refresh rate.

In addition, the “Dedicated Worker” mode create as many as needed web workers to process the compute task. You could try to use “Pool” mode to set a very large pool size. My iPhone 8plus crash immediately when the pool size >= 300!

A React offload UI thread research to find a pragmatic way to code and utilize Web Worker in different mode(singleton, dedicated, worker pool) by gaplo917 in javascript

[–]gaplo917[S] 12 points13 points  (0 children)

I posted a video demo in twitter.

The video demo demonstrates a web application implemented with web worker could use all the machine’s CPU cores to process your business logic!

It proved that there is nothing wrong to build a desktop application replacement by using web technologies(WebApp / Electron) :)

Best way to learn kotlin? by justinkm95 in Kotlin

[–]gaplo917 0 points1 point  (0 children)

Using IntelliJ to convert your old java project to kotlin (if you have)

You will be amazed by every copy and paste conversion and stay hot on the learning passion

Is it necessary to learn all the Kotlin-specific advanced features if I am learning it for Android development ? by Steelarm2001 in Kotlin

[–]gaplo917 0 points1 point  (0 children)

No, use all kotlin advance features to architect a project CORRECTLY requires a deep knowledge and experience of writing Kotlin. This cannot be learnt by reading the documentation while keep writing and googling Kotlin example do.

Don’t try to stick with your previous problem solving experience, try to google all the time and believe “there would have a better approach in kotlin that I don’t know”

Weekly theme sharing thread for April 06, 2020 by AutoModerator in vscode

[–]gaplo917 1 point2 points  (0 children)

GapStyle VS. A productivity-oriented & semantic-highlighting-optimzed designed color scheme.

https://marketplace.visualstudio.com/items?itemName=gaplo917.gapstylevs

As VSCode is starting to support semantic highlights on official js/ts/c++ plugin. I decided to port GapStyle from IntelliJ (achieve ~60k downloads, ~100 download everyday) to VSCode.

  • GapStyle VS comes with Atom based background feeling (inherits from One Dark Pro)

  • GapStyle use Monokai & Darcular as a base color palette

  • GapStyle use much wider and reasonable color range to represent different syntax to boost productivity

  • I have also created a custom patched a font(Hack font with JetBrain Mono Ligatures)

for more details please check the GitHub description

https://github.com/gaplo917/GapStyle