Understanding set-associative cache with a Mathematical problem

The problem I’m trying to solve is:

A set-associative cache consists of 64 lines, or slots, divided into four-line sets. Main memory contains 4K blocks of 128 words each. Show the format of main memory addresses.

My solution:

Main memory size= 128 words/block x 4K block                 = 2^19  byte       //assumptions. 1K=2^10, 1 word=1 byte         

This means, we need 19 bits for memory addressing.

Further assuming, that this cache is operated in blocks of memory, each block needs (128 byte= 2^7 byte) 7 bits out of 19 bits.

Since we can have 64 line / (4 line/set) = 16 sets = 2^4 sets. we need 4 bits to identify the sets.

This leaves 19-7-4=8 bits.

However, my confusion starts when I try to find out how many bits needed for tag.

Option A: If I assume, each block will occupy in a single line (or slot) of the cache, then we need 2 bits for identifying a line within a set. This leaves 8-2=6 bits for tag.

Option B: However, if we assume, a block will filly occupy a set (i.e. 4 lines) in the cache, then we don’t need to spare any bits for identifying lines. This leaves whole 8 bits for tag.

Can anyone help me understand which option is the right way of reasoning. My reasoning goes for option A as the question indicates lines.

The style.css inside magento installation directory is effecting cache

I am very new to Magento. Recently i have to add extra styles to my magento website. So I go to adminpanel -> content-> design->configuration->my theme ->HTML Head

I add the following line

<link rel="stylesheet" type="text/css" media="all" href="https://example.com/my-style/style.css" /> 

Then I save that one. Now new styles are working on my website. But I edited some of the styles through opening the file through Filezilla and edit. After that, I uploaded. Then I noticed that new changes are not coming. So I open https://example.com/my-style/style.css in a browser so I can see that it is not updated the copy. I refresh the page and I open in incognito window. Still the same. But when I open in the same file through editor using FileZilla I can see that it is updated copy.

Then I try to refresh page cache, layout cache but the result is the same.

Please help.

Finding the total cache bits in a set associative cache

This is a question from a Computer Architecture exam and I don’t understand how to get to the correct answer.

Here is the question:

This question deals with main and cache memory only.

Address size: 32 bits
Block size: 128 items
Item size: 8 bits
Cache Layout: 6 way set associative
Cache Size: 192 KB (data only)
Write policy: Write Back

What is the tag size in bits and what is the total number of cache bits?

In order to get the number of tag bits, I find that 7 bits of the address are used for byte offset (0-127) and 8 bits are used for the block number (0-250) (250 = 192000/128/6), therefore 17 bits of the address are left for the tag.

The part I don’t understand is the second part. To find the total number of bits in the cache, I would take (valid bit + tag size + bits per block) * number of blocks per set * number of sets = (1 + 17 + 1024) * 250 * 6 = 1,536,000. This is not the correct answer though.

The correct answer is 17 tag bits and 1,602,048 total bits in the cache. After trying to reverse engineer the answer, I found that 1,602,048 = 1043 * 256 * 6 but I don’t know if that is relevant to the solution because I don’t know why those numbers would be used.

I’d like if someone could explain what I did wrong in my calculation to get a different answer.


Cache maintained by caller app or by provider app in microservices inter-app communication?

Suppose there are app1 and app2 in a microservices. app2 needs to call app1‘s RESTful APIs. Cache is needed since the call will be frequent. So after a successful RESTful call, there will be cache available for app2.

My question is who maintains the cache, app1 or app2? Any comparison between the two? Is there industry best practices?

In addition, are there any differences if there’s a app3 also needs to call the app1‘s APIs?

M2: flushing cache lets page render one time, then blank white page thereafter

I’m working through Alan Storm’s ‘No Frills Magento 2 Layout’ an internal dev server. He walks the reader through small edit, refresh, another small edit, refresh, see what changes, and so on. There are lots of examples. Then I inserted a typo which I couldn’t find, that ended up being whitespace added at the end of 'Magento\Framework\View\Element\Template ' when I copied and paste from the PDF manual.

I then sorted out getting errors enabled, however I managed to get the Magento 2.3.2 install into a bad state where there are white pages on every refresh. Clean the cache and hit F5, the site comes back, but for only one render.

This was a fresh install and I had only executed php bin/magento deploy:mode:set developer as per the install instructions for the module which is part of the book.

I then started an exploration of every command available from the internet in an attempt to be able to hit F5 and just get a page to reload. I issued these two commands:

php bin/magento deploy:mode:set developer php bin/magento cache:disable 

And now the site will refresh with F5 but instead of quickly refreshing, the server grinds for 7 to 10 seconds and then renders Hello World

What mechanism in Magento 2 causes this?
What can a person do to get back to how the site was working as expected before all this?

Right now, I believe the solution is to move this M2 and start over by installing a new fresh instance. But that simply is not acceptable; what happens if a live site starts acting like this? Having to clean cache to render one page is not acceptable nor is disabling cache…

How to cache timestamp based key values with a distributed cache?

I have a dataset in a key value store (similar to Cassandra). The data model is –

Key - ServiceName / timestamp_in_milliseconds value - operation 

In the write side I get some operations for a service and I store them as the key value model above. These operations can come at any frequency, once a day, once an hour or few thousands in a minute.

On read path, I get requests where I need to aggregate all the operations from a time range. The key value store allows me to search through the range.

The latency of getting to key value store is quite high and I want to cache the results in a distributed cache (Similar to Redis) to improve performance.

My dilemma is when I get a request for a particular time range, I have no way of knowing whether there was any data for this time range. Since operations do not necessarily have to exist for every datapoint (millisecond timestamp), if an operation is not found in cache it might mean that either we have to fetch it from key-value store or there was no operation for that timestamp. This would make the application to essentially go to the key value store for every request, rendering the cache useless.

Is there any way to design the cache such that I can reliably fetch the values from cache while reloading it at a genuine cache miss (that is when value is present in store but not in cache) ? Also the scale of data is such that I can not store some nil value for every millisecond.