Old 02-15-2023, 03:15 PM   #1
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default Performance optimization for JSFX

I have developed a JSFX that loads many large image files to display the user interface. Unfortunately, I can't load many JSFX instances into a Reaper project because it quickly fills up my memory. I suspect this is due to the many large image files that each JSFX instance loads. Is there any way to be able to load many JSFX instances into a Reaper project without quickly filling up my RAM?

Last edited by mawi; 05-30-2023 at 11:20 AM.
mawi is offline   Reply With Quote
Old 05-30-2023, 11:21 AM   #2
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

I did a little comparison with JSFX and VST2. Once 100 tracks with one JSFX instance each and then once 100 tracks with one VST2 instance each. Compared to VST2 and VST3, JSFX uses almost twice as much CPU and three times as much RAM. Is there any way to minimize/optimize the CPU and memory consumption of JSFX?

Last edited by mawi; 05-30-2023 at 11:28 AM.
mawi is offline   Reply With Quote
Old 05-30-2023, 11:55 AM   #3
Zeno
Human being with feelings
 
Zeno's Avatar
 
Join Date: Sep 2018
Location: HH
Posts: 916
Default

I'd say it depends on the type of plugin and what it does.

ext_tail_size would be one option you could use.
Another option would be to execute only the parts of the code that are actually needed.


It's hard to say without seeing your code.
Zeno is offline   Reply With Quote
Old 05-30-2023, 12:57 PM   #4
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

Do the same test with e.g. SonicAnomaly S.LA.X. Once 100 tracks with JSFX and 100 tracks with VST2. Do you also have much more CPU and memory consumption with JSFX? What is the reason for that?

vst: https://plugins4free.com/plugin/2593/

jsfx: https://github.com/Sonic-Anomaly/Son...master/Plugins
mawi is offline   Reply With Quote
Old 05-30-2023, 01:16 PM   #5
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

The folder with the image files for my JSFX is about 18MB on the hard disk. When I load my JSFX with the images it consumes about 180MB of RAM per instance.

Last edited by mawi; 05-30-2023 at 03:35 PM.
mawi is offline   Reply With Quote
Old 05-30-2023, 07:49 PM   #6
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Are you resizing the images?

It could be that the images are constantly being resized, this is obviously bad. Put a check in there such that the image is only resized when the window size changes.
James HE is offline   Reply With Quote
Old 05-31-2023, 03:57 AM   #7
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

Yes, I change the image size depending on the window size. But the image size is changed only when the window size is changed. I don't know of any other way to do this. This would also not explain the large RAM consumption for all JSFX loading images. Is this not the case for you?
mawi is offline   Reply With Quote
Old 05-31-2023, 07:33 AM   #8
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

What kind of image files are we talkking about? Because PNG images will usually be stored in compressed format, but when they are loaded into memory they are decompressed, probably talking up width*height*4 bytes of memory.

Also note that a VST might share images across multiple instances, so it doesn't matter if you load 1 or 10 instances; it will load only 1 set of images. AFAIK JSFX won't do this when you load images using gfx_loadimg(), so then you would end up with 10 sets of images, not just 1 set.
Tale is offline   Reply With Quote
Old 05-31-2023, 08:46 AM   #9
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

That's exactly what I noticed as well. I also thought at first it was because of the png files being decompressed. But i couldn't see much difference in RAM use between png, jpg and bmp. I tried to load images via import and gfx_loadimg, but I couldn't see any difference either. Via import I can only load png images. Is this maybe a bug? Is there a way with JSFX to share 1 set of images between multiple instances, like with VST?
mawi is offline   Reply With Quote
Old 05-31-2023, 09:21 AM   #10
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Hmm it may be that we can add jsfx image sharing/deduplication (with copy-on-write), let me look at this.

Last edited by Justin; 05-31-2023 at 09:28 AM.
Justin is offline   Reply With Quote
Old 05-31-2023, 09:59 AM   #11
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

That would be nice!
mawi is offline   Reply With Quote
Old 06-03-2023, 07:53 AM   #12
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

…coming in the next dev builds
Justin is offline   Reply With Quote
Old 06-03-2023, 11:05 AM   #13
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,185
Default

Great, I will test it right away.
mawi is offline   Reply With Quote
Old 08-11-2023, 07:00 PM   #14
Felipe Zanabria
Human being with feelings
 
Join Date: Jan 2022
Location: Misiones, Argentina
Posts: 17
Default

I have also noticed double cpu usage. I've found Verbity's emulation of Air Windows in jsfx, and sure enough: On my Dell Latitude 2120, an instance of Verbity in vst consumes 2%, while the jsfx consumes 5.
There is also a version of thebess plug-in, which vst consumes 5% and js 20.
As a visually impaired person, I prefer to work with js, since the sliders are more transparent, and there are the combo boxes, which also help to label the different options. Another benefit is the task of editing an automation point. In vst the values are floats between 0 and 1, while in js they are exact, like -6 or -12 dB, 50 or 100 ms etc. If jsfx performance improves I can use much more fluently.
Felipe Zanabria is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.