Commit c798bc1a authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfs4: use ConcurrentHashMap for open file tracking

in a highly concurrent environment the ConcurrentHashMap hash map has
a better throughput than synchronized hashmap.

Benchmark                                                (map)   Mode  Cnt       Score       Error  Units
FileTrackerBenchmark.fileTrackerHashMapTest      HashMap  thrpt   25  691051.876 ± 23720.699  ops/s
FileTrackerBenchmark.fileTrackerHashMapTest  ConcHashMap  thrpt   25  792051.898 ± 18111.740  ops/s

Benchmark with 48 concurrent clients.

Update FileTracker to use ConcurrentHashMap to track open files

better throughput in concurrent environment

Acked-by: Lea Morschel
Target: master
parent d3b3cd75
......@@ -21,11 +21,10 @@ package org.dcache.nfs.v4;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import org.dcache.nfs.ChimeraNFSException;
import org.dcache.nfs.status.BadStateidException;
......@@ -51,7 +50,7 @@ public class FileTracker {
* FIXME: get number of threads from RPC service.
private final Striped<Lock> filesLock = Striped.lock(Runtime.getRuntime().availableProcessors()*4);
private final Map<Opaque, List<OpenState>> files = Collections.synchronizedMap(new HashMap<>());
private final Map<Opaque, List<OpenState>> files = new ConcurrentHashMap<>();
private static class OpenState {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment