问题
I am trying to record the Neo4J algorithm execution. I run an algorithm 10 times, however the first run is always significantly longer than the rest of executions. For example:
elapsed time = | 86345.0 | 3417.0 | 3416.0 | 4228.0 | 3369.0 | 3323.0 | 3338.0 | 3370.0 | 3775.0 | 3370.0 //ms
Why is this happening? Is Neo4J smart enough to store already visited (read from DB) vertices in memory, thus from the second execution it reads from memory not the database? My datasets are small enough to fit into memory (and a lot of space is left).
回答1:
Your assumption is correct. Neo4j uses caching on multiple levels:
- mapped memory cache
- object cache
The first run operates on cold caches, so all data must be read from I/O subsystem. Any subsequent access will then benefit from caches.
For a more in-depth explanation see http://docs.neo4j.org/chunked/stable/configuration-caches.html.
来源:https://stackoverflow.com/questions/15482616/neo4j-job-execution-time