-
Notifications
You must be signed in to change notification settings - Fork 763
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
base: uinverse
Are you sure you want to change the base?
Conversation
...ouscompany/business/java/fizzbuzz/packagenamingpackage/impl/caching/LazilyComputedValue.java
Outdated
Show resolved
Hide resolved
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! |
There was a problem hiding this 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.
Also add more smileys to comments! |
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. |
@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? |
@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. |
I was first! I stopped paying for my internet connection 3 months ago so I've had an Edge server for two months already! |
@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. |
@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? |
@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? |
@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... |
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 |
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.