GitHub user cloud-fan opened a pull request:
https://github.com/apache/spark/pull/791
improve performance of MemoryStore#tryToPut by elimating unnecessary lock
It's unefficient to drop memory blocks to disk inside a synchronized block
as IO is slow. As the TODO says, we just need synchronize selecting blocks to
be dropped. So my implementation is: in `ensureFreeSpace`, we iterate entries
and select blocks to be dropped. But instead of dropping block inside
`ensureFreeSpace`, we can just mark selected entries as dropping, and return
these blocks, let the caller do the dropping. When other thread call
`ensureFreeSpace` again, they will skip entries that marked as dropping when
iterating entries. And the caller, `tryToPut`, will do the dropping before put
the new block into entries. In this way, we can do dropping in parallel.
As I don't have a server to test large data set, I just sleep 1 second in
BlockManager#dropFromMemory and set spark.storage.memoryFraction to 0.06 so
that many blocks will be dropped into disk. Result shows my implementation is
much better and I hope someone can test this on real case.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/cloud-fan/spark master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/791.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #791
----
commit bcf9f24d2c63141680432b668f7e59a8d5223a6a
Author: Wenchen Fan(Cloud) <[email protected]>
Date: 2014-05-15T07:34:01Z
enhance performance of MemoryStore#tryToPut by elimating unnecessary lock
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---