-2

In one of my technical interviews I was asked one question on the subject operating system.

Question-> We have two computers. 1st computer is old with less RAM, less ROM, less processing power. 2nd computer is new computer with more RAM, more ROM and more processing power. Let's suppose all the processes in both the computers have been stopped and only one program is run on both the computers whose time complexity is O(n). Is it possible that initially for a short time the slow computer will process the program at a faster speed than the fast computer and only after that the fast computer will show it's real speed. If yes then tell the reason.

I was not able to tell the answer. Plz help!

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 01 '21 at 08:49

1 Answers1

1

You could make up lots of silly reasons why the fast machine could be behind initially, like a program that allocates and initializes as much memory as is available. So it has more startup overhead, if the RAM ratio is greater than the bandwidth ratio.

Or maybe the faster computer is a Transmeta Crusoe, or a virtual x86 emulated by Rosetta-2 on an Apple M1, and the program's machine code has to get translated to native before it can run. Dynamic translation that works like an optimizing compiler (or a JVM's JIT) takes some time at first to make efficient code, instead of just starting interpreting at best speed.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • @Noah: Interesting. Who wrote that / where did you find it? – Peter Cordes Sep 23 '21 at 19:01
  • not sure who wrote it, someone linked it in architecture slack group at my university. Asking – Noah Sep 23 '21 at 19:03
  • @Noah: I found it odd that it didn't have any title / author info in the document, especially given extensive first-person prose and descriptions of personal dislike for XCode's debugger. – Peter Cordes Sep 23 '21 at 19:07
  • oof. Deleted as I realized w.o knowing the author it might not be okay to share. But then remembered the preface so [heres](https://drive.google.com/file/d/1WrMYCZMnhsGP4o3H33ioAUKL_bjuJSPt/view) the link again. For posterity, link to this was first comment. – Noah Sep 23 '21 at 19:11
  • 1
    @Noah: There's got to be a better Q&A to leave this link in where future readers might find it. There don't seem to be any [apple-m1][cpu-architecture] Q&As yet, but [C++ Optimize Memory Read Speed](https://stackoverflow.com/a/67975090) is at least about performance on one. – Peter Cordes Sep 23 '21 at 20:35
  • yeah, just realize you would probably like it and your mention of M1 here reminded me :/ – Noah Sep 23 '21 at 22:24
  • 1
    One could also make maybe not so silly reasons why the "slower" machine would remain faster. If processing power is peak, the slower machine might perform nearer its peak than the faster machine (e.g., SIMD width/core count will not help a single gcc thread). The slower machine might have a cache hierarchy/memory system that fits the program better. Even for the question, the old system might have faster start-up time (I/O performance or OS overheads). Also, a multithreaded program will take time to spawn threads, having fewer cores could lead to less start-up overhead. –  Sep 30 '21 at 18:00
  • @PaulA.Clayton: Indeed, but then we have to parse semantics of what "faster" even means. I chose to limit it to "faster at this task/workload", otherwise whoever told you the machine was faster didn't do a good job of picking a representative benchmark. (And/or there are many possible answers, and I didn't want to get into whether it even makes sense to say there's any objective sense in which a machine can be said to be faster without qualifications, if that's not always true.) But yes good examples, thanks for the comment. – Peter Cordes Sep 30 '21 at 18:14