0
$\begingroup$

I was messing around with a reactive-based frameworks and found it very expressive. Unfortunately, most of them are using techniques that are not very efficient on CPU cashing mechanism such as calling indirect code, and traversing sometimes big collections of subscribers, some of which are readonly, but some can mutate them. That made me thinking of some optimizations that could be implemented : for example, you can imagine that when a core encounters an object that broadcast changes, which is implemented as calling indirect functions, the cpu may miss that data and spend hundreds of cycles loading necessary information. That makes some potential application domains to not be populated with reactive approaches. So my question is that if it would be possible to make it such that cores can be delegated execution of such code in parallel? Or am i mistaken and this kind of code could still be efficiently processed due to all speed-up tricks in modern cpus?

And if the former is true, how to make cpu cores signal they companions in multiprocessor cpu to load pieces of data so they handle them concurrently?

$\endgroup$
  • $\begingroup$ (The goal of making (good) use of all of a processor's memory bandwidth is not unheard of. Luckily, energy efficient has become a topic of late.)(The faster the main memories run, the more they get behind (core speed, that is).) $\endgroup$ – greybeard Jan 25 at 23:05
1
$\begingroup$

CPUs are developed with typical code in mind. For example, indirect function calls are no problem - the destination of such a function call will be predicted, just as we do with branch prediction.

Remember that "hundreds of cycles" are only "tens of nanoseconds". Typically, 3,000 cycles is just one microsecond. So if a programming pattern wastes "hundreds of cycles", that's no big deal and no reason not to use that pattern. "Traversing big collections of subscribers" - there are efficient methods for doing so.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.