Hi All,

*TL;DR:  Is it possible to optimize code to make use of L1 
cache/prefetching better.*

I am working on Google's project Lovefield 
https://github.com/google/lovefield

I am performing some research on the Lovefield code and investigating 
whether I can optimize some code paths using L1 caching. This is inspired 
from the blog post 
http://mechanical-sympathy.blogspot.com/2011/07/write-combining.html 
for reference. 
<http://mechanical-sympathy.blogspot.com/2011/07/write-combining.html>

In my experimentation, I have two for loops initially. To increase locality 
of access so that some code remains in *L1 cache longer and have less cache 
misses*, we wrote a blocked version of the code, where the inner for loop 
is accessed in blocks. My experimentation is here. 
https://github.com/sowmyasb/sowmyasb.github.io/blob/master/blocked_nested_loop.js
testBlockedNestedLoop() is the improvement over testNestedLoop().



*You can run the code hosted here: http://sowmyasb.github.io/ 
<http://sowmyasb.github.io/>The values shown are time taken to run the code 
in milliseconds.*

There is 30%-40% improvement in runtime on average.  But the blockSize at 
which, the time taken to run is the least is around 200. 
and each Employee object is a reference, so its size is around 4 
bytes(say), So it seems like L1 cache is just 200*4  =800 bytes. But L1 
cache= 32KB - 64KB. *So the optimal blockSize should be more than that.*

Do any users or anyone in the V8 team, know why there is an improvement and 
what is the significance of block size in this problem. I know that the 
improvement could be due to prefetching of data also but the range of 200 
block size has something to do with caches. But we dont know what is 
happening there!

Any ideas are appreciated!


Sowmya Sree B




-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to