-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VST3: State performance issue #478
Comments
Update: Detailsdiff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp
index a9b99416..e96580c9 100644
--- a/distrho/src/DistrhoPluginVST3.cpp
+++ b/distrho/src/DistrhoPluginVST3.cpp
@@ -954,14 +954,27 @@ public:
bool fillingKey = true; // if filling key or value
char queryingType = 'i'; // can be 'n', 's' or 'p' (none, states, parameters)
- char buffer[512], orig;
- buffer[sizeof(buffer)-1] = '\xff';
+ char orig;
+ //char buffer[512];
+ //buffer[sizeof(buffer)-1] = '\xff';
+ int bufferSize = 512;
+ char* buffer = new char[bufferSize];
+ buffer[bufferSize - 1] = '\xff';
+ int allocationCount = 0;
v3_result res;
for (int32_t terminated = 0, read; terminated == 0;)
{
+ allocationCount += 1;
+ if (allocationCount > 8 && allocationCount % 2 == 0 && bufferSize < 1024 * 1024)
+ {
+ bufferSize *= 2;
+ char* newBuffer = new char[bufferSize];
+ delete[] buffer;
+ buffer = newBuffer;
+ }
read = -1;
- res = v3_cpp_obj(stream)->read(stream, buffer, sizeof(buffer)-1, &read);
+ res = v3_cpp_obj(stream)->read(stream, buffer, bufferSize - 1, &read);
DISTRHO_SAFE_ASSERT_INT_RETURN(res == V3_OK, res, res);
DISTRHO_SAFE_ASSERT_INT_RETURN(read > 0, read, V3_INTERNAL_ERR);
And it improved the performance a lot.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My plugin has ~50MiB of state.$O(N^2)$ ):
It looks like DPF reallocates the buffer for every 512 bytes, and this causes significant performance issue (It might be
Simulation Source
Looks like there's room for improvement.
Example: doubling the buffer size for every 2 allocations if there are more than 512*8 bytes:
Details
The text was updated successfully, but these errors were encountered: