diff options
author | Simon Marlow <marlowsd@gmail.com> | 2008-10-23 08:07:49 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2008-10-23 08:07:49 +0000 |
commit | 4af25e1a72f2d0f1f523fe5b13c71f1b3dc7a5a5 (patch) | |
tree | 4572a4687c5a6b2d02195870eabef32383a2cdbc /rts | |
parent | 05dce654a3c65e1c7a68ca55f990eed8bd3ec700 (diff) | |
download | haskell-4af25e1a72f2d0f1f523fe5b13c71f1b3dc7a5a5.tar.gz |
Pad Capabilities and Tasks to 64 bytes
This is just good practice to avoid placing two structures heavily
accessed by different CPUs on the same cache line
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Capability.h | 6 | ||||
-rw-r--r-- | rts/Task.c | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/rts/Capability.h b/rts/Capability.h index 89b813f6d3..dc0a28ea57 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -106,8 +106,10 @@ struct Capability_ { StgTRecChunk *free_trec_chunks; StgTRecHeader *free_trec_headers; nat transaction_tokens; - -}; // typedef Capability, defined in RtsAPI.h +} // typedef Capability is defined in RtsAPI.h + // Capabilities are stored in an array, so make sure that adjacent + // Capabilities don't share any cache-lines: + ATTRIBUTE_ALIGNED(64); #if defined(THREADED_RTS) diff --git a/rts/Task.c b/rts/Task.c index 0ec60f7508..7120436bb4 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -114,7 +114,8 @@ newTask (void) #endif Task *task; - task = stgMallocBytes(sizeof(Task), "newTask"); +#define ROUND_TO_CACHE_LINE(x) ((((x)+63) / 64) * 64) + task = stgMallocBytes(ROUND_TO_CACHE_LINE(sizeof(Task)), "newTask"); task->cap = NULL; task->stopped = rtsFalse; |