-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Speed up adding fixings #2085
Speed up adding fixings #2085
Conversation
You're right, we should review this, but this way index observers don't get a notification when the fixing is added (which currently happens when the ObservableValue is reassigned). We should probably skip wrapping the history in the ObservableValue and write a custom implementation of addFixing(s) that notifies observers explicitly. |
On the other hand, good to see that the tests caught the problem :) |
Yes they did. I just proceeded with "minimal design thoughts", which does the job. We can of course discuss how to simplify that further. |
Ok now there is some obvious overlap between my new |
So based on the changes here, would you remove the |
I'm not sure. A method name like Off the top of my head I would give |
Ok I can try to clean that up, thanks. |
The Codacy error looks like a false positive. Can I fix that myself by adding Not sure about the checks that are still yellow? |
Ah I changed the behavior of Index::addFixings() when an invalid fixing is provided, let me change that back |
I happy with this now, seeing the desired performance improvement and all tests on our side passing. |
The checks were yellow because the commits were pushed by @damienbarker and he didn't contribute before (as in, he didn't have a commit authored by him merged) so GitHub waits for my approval before running the tests. It's something they added a while ago because people were opening fake PRs all around GitHub to mine Bitcoin in the CI builds... |
Also, I was thinking about maybe hiding the new methods of |
Ah yes, that's because I pushed the commits via our own CI which uses that user. And yes I can hide the new method, will also check the old ones. |
Ok, thanks. No hurry, though, I'm cutting 1.36 in the next days so I'll get back to this later—I'd be a bit uncomfortable putting this in at the last minute. |
Sure! |
I hid the newly added methods. I think we should deprecate other public methods in IndexManager before hiding them though? Let's discuss after the 1.36 release. |
We rely on
Index::addFixing()
to add historical fixings. When we add a large number of fixings (e.g. 10k - 100k) we see that this takes quite long, in the order of seconds, maybe 10s.There is
Index::addFixings()
which is called fromIndex::addFIxing()
and allows to add multiple fixings at once, but it can not be used generically since inflation indices overridesIndex::addFixing()
with their own logic. We have some custom index implementations which overwrite this method too.In the end, they all call into
Index::addFixings()
though, so it seems this is the right place for a performance optimization. This is what I am trying to do here. I observe a speed up of >100x when many fixings are set, this is achieved by avoiding the copy of the time series storing the historical fixings on each call ofIndex::addFixings()
.