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

Increase performance by computing multiply needed values lazily #478

Open
wants to merge 2 commits into
base: uinverse
Choose a base branch
from

Conversation

rillig
Copy link

@rillig rillig commented Jul 18, 2020

When I looked at the NoFizzNoBuzzStrategy, I noticed that it computes twice whether one number is divisible by another. Given that the involved numbers are not constants, division is one of the most expensive machine instructions, and the instruction latency varies between 7 and 90 cycles.

Therefore it is a good idea to cache the result of this expensive computation. An additional benefit is that the costly division is only done when it is actually needed by the code. Currently this is not the case since both expressions are always evaluated, but with future modifications it may become useful.

Updated version of #447.

@NathanJAdams
Copy link

This is a top quality effort, I know this because I remember reading a chapter of the Gang of Four book about lazy loading one time back in college so it must be good. Keep up the good work!

Copy link

@sheepdreamofandroids sheepdreamofandroids left a comment

Choose a reason for hiding this comment

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

Please provide accompanying unit-, component- and integration-tests.

@sheepdreamofandroids
Copy link

Also add more smileys to comments!

@Voultapher
Copy link

Voultapher commented Aug 27, 2020

Hmmm, we are already quite close to the metal here, I remember hearing that synchronized operations could add a lot of startup time for the JVM, maybe we should go a bit deeper and do this hot path in inline assembly, so that we avoid the overhead of synchronized, and just use memory barriers instead, JNI can support that and having JNI could be useful for some of the upcoming efforts.

@wizzwizz4
Copy link

@Voultapher That would help, but I think the caching is still a good idea. Caching is only really a problem in practice if the results are changing, and mathematics isn't exactly changing on us, is it?

@Tylersuard
Copy link

@Voultapher We are running close to the metal... Have you thought about getting us an Edge server?

It's a lot like a cloud server, but it's on-premises, so there's no need to connect to the cloud. Neat, huh? It's a brand new tech that came out just last month. Let me know what you think.

@sheepdreamofandroids
Copy link

It's a lot like a cloud server, but it's on-premises, so there's no need to connect to the cloud. Neat, huh? It's a brand new tech that came out just last month. Let me know what you think.

I was first! I stopped paying for my internet connection 3 months ago so I've had an Edge server for two months already!

@Voultapher
Copy link

@Tylersuard currently talking to finance, they are somewhat skeptical, but open to the idea of being a technological leader, something we obviously cannot be without Edge infra.

@Tylersuard
Copy link

@sheepdreamofandroids That's great! I'm trying to unpack the implications of that. Since you are connecting to your own server for content, you probably downloaded the internet and are hosting it there. Do you update the internet often, or are you content with just leaving it be?

@Tylersuard
Copy link

@Voultapher I talked to a consultant. I asked them about edge servers, they said they would be willing to install one for 4x our yearly cloud server bill. A bit steep, but it might be worth it for the added security. I mean, all our data would stay on-premises! Can you imagine?

@sheepdreamofandroids
Copy link

@Tylersuard , I update my private internet all the time. I'm actually ahead by three full months already. You should see what Bitcoin is doing here! Wheeeeeee...

@jedwards1211
Copy link

Would be good to add an HTTP route we can call to manually trigger the lazy computation so we can precompute it during downtime if we anticipate an upcoming period of high load

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.

8 participants