Skip to content
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

MM tweaks still #415

Merged
merged 8 commits into from
Sep 11, 2020
Merged

MM tweaks still #415

merged 8 commits into from
Sep 11, 2020

Conversation

paulfd
Copy link
Member

@paulfd paulfd commented Sep 9, 2020

One of the consuming operation is looping through the sources for nothing since we're basically never hitting the right sources (or targets) for a given voice id. This patch adds a container that maps a NumericId<Region> to a set of source indices. This way we have one lookup through the container, and an iteration to go through all the relevant sources.

http://box.ferrand.cc/sfizz-reports/2020-09-09-mm-tweaks-still.html

Notice that this completely remove the "residual" part almost, which was where all these failed lookups were going to. What's left now is the lookup per-voice for each modulation target on rendering each block, but I think this could be memorized within the voice.

@paulfd paulfd changed the title Mm tweaks still MM tweaks still Sep 9, 2020
@paulfd
Copy link
Member Author

paulfd commented Sep 9, 2020

4ccce85 seems to be the last of the low hanging fruit there. Searching through the targets for the key was quite costly, and the search happens for n_targets * n_modulation_keys in each render block. Saving the target ids on voice start seems to do the trick here, at the cost of more private variable for the voice.

http://box.ferrand.cc/sfizz-reports/2020-09-09-mm-tweaks-still-2.html

@paulfd paulfd requested a review from jpcima September 9, 2020 23:04
@paulfd
Copy link
Member Author

paulfd commented Sep 9, 2020

We now see more clearly that there are some big spikes in dispatch duration (Dispatch duration (avg/max): 4.42/1278.73 µs) that probably stem from all the polyphony checks.

@jpcima
Copy link
Collaborator

jpcima commented Sep 10, 2020

This PR modifies the vstgui submodule, you should probably undo that.

@jpcima
Copy link
Collaborator

jpcima commented Sep 10, 2020

Yes, it's a bit a solution like this I wish to have, but it can be even better.

  1. Given the maximum region is a known number after loading sfz, the hashtable can be removed in favor of an array.
  2. The index vector can be replaced with a linked list. The link pointers are stored inside the source or target.

Imo, sfizz really needs a generic intrusive list structure.
The midi processing could take avantage of it as well.

@paulfd
Copy link
Member Author

paulfd commented Sep 10, 2020

Yes, it's a bit a solution like this I wish to have, but it can be even better.

1. Given the maximum region is a known number after loading sfz, the hashtable can be removed in favor of an array.

I chose the hash table because it seemed to me that the number() could actually be -1 when the source was a CC and not linked to a region. I thus wondered if you had only this special case in mind or if, in the future, we could really expect this number to be anything and figured this was an easy compromise to make and check if this was indeed a big gain. I'm not against an array though. We could even have 2, one for positive and one for negative NumericId, assuming int stays as the representation of it 🙂

2. The index vector can be replaced with a linked list. The link pointers are stored inside the source or target.

Imo, sfizz really needs a generic intrusive list structure. The midi processing could take avantage of it as well.

I guess the "sister voices" are kind of like this no? I did this for the sister voices because they can change and be reassigned to other rings, but in this case this data structure is quite fixed, so I don't know. I don't have a strong argument against though. How does this help midi?

@paulfd
Copy link
Member Author

paulfd commented Sep 10, 2020

This PR modifies the vstgui submodule, you should probably undo that.

Yes I'm always happy when submodules do this to me !

@jpcima
Copy link
Collaborator

jpcima commented Sep 11, 2020

How does this help midi?

In the PR #407 it's basically implementing an adhoc linked list.
The sister ring it's the same thing, except circular.

@paulfd
Copy link
Member Author

paulfd commented Sep 11, 2020

Yes, it's a bit a solution like this I wish to have, but it can be even better.

1. Given the maximum region is a known number after loading sfz, the hashtable can be removed in favor of an array.

So I tested this using 2 arrays (for negative and positive indices). The difference in performance seems non-existent, so it might not be necessary to bother.

https://box.ferrand.cc/sfizz-reports/2020-09-11-hashmap-vs-vector-mm.html

@jpcima
Copy link
Collaborator

jpcima commented Sep 11, 2020

I don't understand: why does this not use an ordinary vector?
Regions don't have negative identifiers.

@paulfd
Copy link
Member Author

paulfd commented Sep 11, 2020

I guess I am just extremely confused about the need and use of this NumericId then, but OK... Anyway, the result is still the same, using any kind of vector over hashmaps there seems to have no impact on actual performance.

@jpcima jpcima force-pushed the mm-tweaks-still branch 6 times, most recently from af56c46 to d7a1d2f Compare September 11, 2020 15:35
@paulfd paulfd merged commit bf0786c into sfztools:develop Sep 11, 2020
@paulfd paulfd deleted the mm-tweaks-still branch September 11, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants