Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kraken] - Improve performance of checksum computation #4999

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

ivelkov
Copy link
Contributor

@ivelkov ivelkov commented Feb 7, 2025

The original code is compiling a Regex in a loop which is inefficient in an active system. What I'm seeing is that most of the time, I/O threads spend on this Pattern compilation.

nioEventLoopGroup-18-1" #76 [85] prio=10 os_prio=0 cpu=78812.80ms elapsed=7034.36s tid=0x00007f4404302110 nid=85 runnable [0x00007f44746ce000] java.lang.Thread.State: RUNNABLE at java.util.regex.Pattern$CharProperty.study([email protected]/Pattern.java:4119) at java.util.regex.Pattern$Start.<init>([email protected]/Pattern.java:3777) at java.util.regex.Pattern.compile([email protected]/Pattern.java:1967) at java.util.regex.Pattern.<init>([email protected]/Pattern.java:1576) at java.util.regex.Pattern.compile([email protected]/Pattern.java:1101) at java.lang.String.replaceFirst([email protected]/String.java:3025) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum$1.load(KrakenStreamingChecksum.java:27) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum$1.load(KrakenStreamingChecksum.java:21) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3574) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2316) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2190) - locked <0x00000000eaa1d588> (a com.google.common.cache.LocalCache$StrongAccessEntry) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2080) at com.google.common.cache.LocalCache.get(LocalCache.java:4017) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4040) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4989) at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4996) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum.addBigDecimalToCrcString(KrakenStreamingChecksum.java:34) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum.addOrderToCrcString(KrakenStreamingChecksum.java:38) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum.lambda$createCrcString$1(KrakenStreamingChecksum.java:49) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum$$Lambda/0x00007f4478cf79a8.accept(Unknown Source) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept([email protected]/ForEachOps.java:184) at java.util.stream.SliceOps$1$1.accept([email protected]/SliceOps.java:200) at java.util.TreeMap$KeySpliterator.tryAdvance([email protected]/TreeMap.java:3123) at java.util.stream.ReferencePipeline.forEachWithCancel([email protected]/ReferencePipeline.java:129) at java.util.stream.AbstractPipeline.copyIntoWithCancel([email protected]/AbstractPipeline.java:527) at java.util.stream.AbstractPipeline.copyInto([email protected]/AbstractPipeline.java:513) at java.util.stream.AbstractPipeline.wrapAndCopyInto([email protected]/AbstractPipeline.java:499) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential([email protected]/ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential([email protected]/ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate([email protected]/AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach([email protected]/ReferencePipeline.java:596) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum.createCrcString(KrakenStreamingChecksum.java:49) at info.bitrich.xchangestream.kraken.KrakenStreamingChecksum.createCrcChecksum(KrakenStreamingChecksum.java:60) at info.bitrich.xchangestream.kraken.KrakenStreamingAdapters.adaptOrderbookMessage(KrakenStreamingAdapters.java:103) at info.bitrich.xchangestream.kraken.KrakenStreamingMarketDataService.lambda$getOrderBook$0(KrakenStreamingMarketDataService.java:52)

@ivelkov
Copy link
Contributor Author

ivelkov commented Feb 12, 2025

@timmolter, please check

@timmolter timmolter merged commit 3336c54 into knowm:develop Feb 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants