There is a 3GB local cache in my service(the total mem of my server is 16GB), by using ZGC in JDK11, I found out that the concurrent mark time is too long in each cycle(almost 5 seconds if there are 2 concurrent threads).
So I'm wondering if there is a way that ZGC just skips marking this local cache?
I have already tried dividing this local cache into two layers of cache, the first layer is Caffeine, and the second layer is off-heap Cache. But it didn't work.
It can't. ZGC will mark and collect the entire heap and there's no way to change that.
Since ZGC is not generational, it is technically impossible to do a partial collection safely. Any reachable object in the portion of the heap that you don't mark could reference any of the objects in portion that you are collecting. Including any that are not otherwise reachable. So if ZGC didn't mark the entire heap, reachable objects could be deleted!
If your problem is that GC cycles are taking too long, your options are:
You could also try using G1GC instead.
Or you could rearchitect your service so that you can run multiple instances; e.g. by sharding the data in the service.