Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:37:39+00:00 2026-06-12T13:37:39+00:00

How do I determine by testing writes to cache the type of cache (write

  • 0

How do I determine by testing writes to cache the type of cache (write back/through)? I could use a similar method as I did to determine the levels and size of cache by recording the time to modify cache, but I will need to compare with something. eg. if the time is significantly shorter that a known L1 write through cache, I can say its write back. However, I will need a base line to compare with won’t I?

Heres my attempt at GitHub

The main idea is:

  • if its write through, time taken to write x vs x * 100 times is approximately 100 times
  • if its write back, time will be about the same?

So the time the loop for WRITES_BASE times vs time for WRITES times minus of their respective times to execute loops only (no memory access), and compare them … this gives me the impression that my Core i3 2100 has all write through caches …

16, 0.03, 1.04 (31.28) 
128, 0.07, 2.31 (31.78) 
2048, 0.10, 3.19 (31.74) 

The above values are: test size (KB), time for WRITES_BASE, time for WRITES (t(WRITES)/t(WRITES_BASE))

I am guessing the problem with my experiment is I haven’t eliminated the time difference that I am running WRITES more times…

UPDATE

An oddity I noticed is if I keep my WRITES = 64 * WRITES_BASE, then if I have my WRITES_BASE = 4 million.

16, 0.01, 0.13 (17.16) 
128, 0.01, 0.29 (31.60) 
2048, 0.01, 0.41 (30.53) 

If I increase WRITES_BASE = 16 million

16, 0.02, 0.52 (25.53) 
128, 0.04, 1.16 (31.74) 
2048, 0.05, 1.57 (31.89)

Notice, when WRITES_BASE is smaller, the difference between the times are less, perhaps telling me L1 is a write back cache. However, since its not always true, eg. when I increase WRITES_BASE, I wonder if I am having some logic error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:37:40+00:00Added an answer on June 12, 2026 at 1:37 pm

    You can’t really distinguish between a writeback cache and a write-through cache with this procedure. Consider: If you’re using a writeback cache, it takes X time to execute the instructions in the loop, and Y time to write it back. Y is not measured by your code (you don’t have any timing around an explicit cache flush or similar). When you loop N times, it takes N * X time, plus Y after your code is done executing to flush the cache.

    With a write-through cache, X is higher, and Y is zero. But the ratio of the single loop to many loops is the same. Thus, you can’t tell the difference with this procedure.

    That said, there are ways you can detect this. The key is to force the cache to flush its cache lines while you’re timing. Try comparing how long it takes to write various sizes of arrays. Between writes ensure that any writeback cache is flushed by reading a lot of unrelated data (note: don’t just allocate a large array and read from it without writing to it ever – write to it once at program startup, then read the whole thing between timing runs. Otherwise all the pages in the array might point to the same zeroed-out page in physical memory, depending on your OS).

    You could also try seeing when writing lots of data influences the speeds of reads. In a write-through cache, reads should never take longer just because you wrote data recently. In a write-back cache, reads may have to wait for cache flushes – so timing reads on their own vs immediately after writes may give you some interesting results as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using EF 5 and am trying to use the ShouldLog method to determine
I'm currently doing some testing to determine the performance implications of including an index
To determine the exact number of lines in a file I currently use: if(exec(wc
To determine the file type of an attached file, I used the OS file
I'm trying to determine the user agent string for surface RT for testing purposes.
For testing purposes, to determine how a protocol implementation behaves in the presence of
Im trying to use typeof to determine whether or not a variable is undefined:
I'm about to start testing an intranet web application. Specifically, I've to determine the
I'm uploading a csv from a form. I'm trying to use mysql_affected_rows to determine
I have the following JUnit test. The method that I'm testing is quite simple,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.