Skip to content

Precompute annuities#1965

Merged
lballabio merged 1 commit into
lballabio:masterfrom
turintech:feature/smmdrift-calculator-performance
May 9, 2024
Merged

Precompute annuities#1965
lballabio merged 1 commit into
lballabio:masterfrom
turintech:feature/smmdrift-calculator-performance

Conversation

@eleanorTurintech
Copy link
Copy Markdown
Contributor

Pre-computation of Annuities: The updated code introduces a pre-computation of annuities for all rates and stores them in a vector. This avoids repeated calls to cs.coterminalSwapAnnuity() within the nested loops, potentially reducing computational overhead and improving performance.

Corresponding unit test runs ~30% faster on a single processor (standard build, g++ 11.4.0)

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 6, 2024

Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 6, 2024

CLA assistant check
All committers have signed the CLA.

// < W(k) | P(j+1)/P(n) > =
// = SR(j+1) a(j+1,k) A(j+1) / P(n) + SR(j+1) < W(k) | A(j+1)/P(n) >
Real annuity = cs.coterminalSwapAnnuity(numberOfRates_,j+1);
Real annuity = annuities[j+1];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the same vector annuities be used also in the other loop ~20 lines below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I'll make that change too, thanks for pointing it out. In fact the quantitative results stated above were including this change, but I forgot to add it when making the final PR.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks.

@eleanorTurintech eleanorTurintech force-pushed the feature/smmdrift-calculator-performance branch from 5f3b8e0 to 3dabf86 Compare May 7, 2024 17:20
@lballabio lballabio added this to the Release 1.35 milestone May 9, 2024
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 72.497% (+0.001%) from 72.496%
when pulling 3dabf86 on turintech:feature/smmdrift-calculator-performance
into 41b7ddc on lballabio:master.

@lballabio lballabio merged commit 40c6e77 into lballabio:master May 9, 2024
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 9, 2024

Congratulations on your first merged pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants