neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First request after app start is not instant

magaton opened this issue · comments

After spring boot from examples starts, I can see schema correctly augmented, but the first request takes significantly longer than the subsequent (although different) ones.
I am executing the query from my locally running playground.

This happens every time, which makes me think that it could be some compilation process going on

If that is the case, can't this happen during app start time, not with the 1st request?

Have you traced where the time is consumed? I doubt that it is because of this library.

Yes, I have. The problem seems to be in neo4j java driver.
My environment: Osx Big Sur, jdk 11

I executed 2 graphql requests from CommandLineRunner and enabled TRACE level logging.

1st takes 6s, 2nd, 50ms.
Here is what is in logs before executing request1

2021-04-26 21:16:28,269 acme [reactor-http-nio-3] TRACE org.neo4j.driver.ConnectionPool - Acquiring a connection from pool towards localhost:7687
2021-04-26 21:16:33,291 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.c.DefaultChannelId - -Dio.netty.processId: 27195 (auto-detected)
2021-04-26 21:16:33,293 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.shaded.io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
2021-04-26 21:16:33,293 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.shaded.io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
2021-04-26 21:16:33,296 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.u.NetUtilInitializations - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1%lo0)
2021-04-26 21:16:33,297 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.shaded.io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file /proc/sys/net/core/somaxconn. Default: 128
2021-04-26 21:16:33,299 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.c.DefaultChannelId - -Dio.netty.machineId: 38:f9:d3:ff:fe:51:b3:61 (auto-detected)
2021-04-26 21:16:33,311 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.u.ResourceLeakDetector - -Dorg.neo4j.driver.internal.shaded.io.netty.leakDetection.level: simple
2021-04-26 21:16:33,311 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.u.ResourceLeakDetector - -Dorg.neo4j.driver.internal.shaded.io.netty.leakDetection.targetRecords: 4
2021-04-26 21:16:33,335 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 24
2021-04-26 21:16:33,335 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 24
2021-04-26 21:16:33,335 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
2021-04-26 21:16:33,335 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
2021-04-26 21:16:33,335 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
2021-04-26 21:16:33,336 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.n.b.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
2021-04-26 21:16:33,347 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
2021-04-26 21:16:33,347 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
2021-04-26 21:16:33,347 acme [Neo4jDriverIO-2-1] DEBUG o.n.d.i.s.i.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
2021-04-26 21:16:33,370 acme [Neo4jDriverIO-2-2] TRACE o.n.driver.ChannelConnectedListener - [0xfa5f8e61][localhost:7687][] Channel [id: 0xfa5f8e61, L:/127.0.0.1:53603 - R:localhost/127.0.0.1:7687] connected, initiating bolt handshake
2021-04-26 21:16:33,394 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.i.n.buffer.AbstractByteBuf - -Dorg.neo4j.driver.internal.shaded.io.netty.buffer.checkAccessible: true
2021-04-26 21:16:33,394 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.i.n.buffer.AbstractByteBuf - -Dorg.neo4j.driver.internal.shaded.io.netty.buffer.checkBounds: true
2021-04-26 21:16:33,395 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.i.n.u.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: org.neo4j.driver.internal.shaded.io.netty.util.ResourceLeakDetector@45b42112
2021-04-26 21:16:33,398 acme [Neo4jDriverIO-2-2] DEBUG o.n.driver.ChannelConnectedListener - [0xfa5f8e61][localhost:7687][] C: [Bolt Handshake] [0x6060b017, 516, 260, 4, 3]
2021-04-26 21:16:33,403 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096
2021-04-26 21:16:33,403 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2
2021-04-26 21:16:33,403 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
2021-04-26 21:16:33,403 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
2021-04-26 21:16:33,403 acme [Neo4jDriverIO-2-2] DEBUG o.n.d.i.s.io.netty.util.Recycler - -Dio.netty.recycler.delayedQueue.ratio: 8
2021-04-26 21:16:33,428 acme [Neo4jDriverIO-2-2] DEBUG org.neo4j.driver.HandshakeHandler - [0xfa5f8e61][localhost:7687][] S: [Bolt Handshake] 4.2
2021-04-26 21:16:33,446 acme [Neo4jDriverIO-2-2] DEBUG o.n.driver.OutboundMessageHandler - [0xfa5f8e61][localhost:7687][] C: HELLO {principal="neo4j", routing=NULL, scheme="basic", credentials="******", user_agent="neo4j-java/4.2.4-e37138cc0a7d6043568bd325455548e13b67b4e6"}
2021-04-26 21:16:33,451 acme [Neo4jDriverIO-2-2] TRACE o.n.driver.OutboundMessageHandler - [0xfa5f8e61][localhost:7687][] C: 0081b101a5897072696e636970616c856e656f346a87726f7574696e67c086736368656d658562617369638b63726564656e7469616c738561646d696e8a757365725f6167656e74d0396e656f346a2d6a6176612f342e322e342d65333731333863633061376436303433353638626433323534353535343865313362363762346536
2021-04-26 21:16:33,455 acme [Neo4jDriverIO-2-2] TRACE org.neo4j.driver.ChunkDecoder - [0xfa5f8e61][localhost:7687][] S: 002eb170a2867365727665728b4e656f346a2f342e322e348d636f6e6e656374696f6e5f696489626f6c742d33363532
2021-04-26 21:16:33,459 acme [Neo4jDriverIO-2-2] TRACE org.neo4j.driver.ChunkDecoder - [0xfa5f8e61][localhost:7687][] S: 0000
2021-04-26 21:16:33,463 acme [Neo4jDriverIO-2-2] TRACE o.neo4j.driver.InboundMessageHandler - [0xfa5f8e61][localhost:7687][] S: b170a2867365727665728b4e656f346a2f342e322e348d636f6e6e656374696f6e5f696489626f6c742d33363532
2021-04-26 21:16:33,465 acme [Neo4jDriverIO-2-2] DEBUG o.n.driver.InboundMessageDispatcher - [0xfa5f8e61][localhost:7687][] S: SUCCESS {server="Neo4j/4.2.4", connection_id="bolt-3652"}
2021-04-26 21:16:33,467 acme [Neo4jDriverIO-2-2] DEBUG org.neo4j.driver.NettyChannelTracker - Channel [0xfa5f8e61] created. Local address: /127.0.0.1:53603, remote address: localhost/127.0.0.1:7687
2021-04-26 21:16:33,468 acme [Neo4jDriverIO-2-2] DEBUG org.neo4j.driver.NettyChannelTracker - Channel [0xfa5f8e61] acquired from the pool. Local address: /127.0.0.1:53603, remote address: localhost/127.0.0.1:7687
2021-04-26 21:16:33,475 acme [Neo4jDriverIO-2-2] DEBUG o.n.driver.OutboundMessageHandler - [0xfa5f8e61][localhost:7687][bolt-3652] C: BEGIN {}
2021-04-26 21:16:33,475 acme [Neo4jDriverIO-2-2] TRACE o.n.driver.OutboundMessageHandler - [0xfa5f8e61][localhost:7687][bolt-3652] C: 0003b111a0

And here is what is in logs before request2:

2021-04-26 21:16:33,535 acme [reactor-http-nio-6] TRACE org.neo4j.driver.ConnectionPool - Acquiring a connection from pool towards localhost:7687
2021-04-26 21:16:33,536 acme [Neo4jDriverIO-2-2] DEBUG org.neo4j.driver.NettyChannelTracker - Channel [0xfa5f8e61] acquired from the pool. Local address: /127.0.0.1:53603, remote address: localhost/127.0.0.1:7687

In the first case, the next line is logged 5s after

Acquiring a connection from pool towards localhost:7687

Any idea?

No, sorry. Please report this issue in the driver project.