Chat Logs

  1. * yaboishady2 joined #java
  2. * OmniRadix698 joined #java
  3. * Fiji_ joined #java
  4. * Bharton joined #java
  5. * lockdown joined #java
  6. * LtHummus joined #java
  7. * Bharton joined #java
  8. * Bharton joined #java
  9. * Bharton joined #java
  10. * llanhmock joined #java
  11. * t3ch joined #java
  12. * stfstfm joined #java
  13. * hwpplayer1 joined #java
  14. * julemand101 joined #java
  15. * gurrkin joined #java
  16. * Cae2 joined #java
  17. * gurrkin joined #java
  18. * jreicher joined #java
  19. * MikeBux joined #java
  20. * Anaphaxeton joined #java
  21. * MikeBux joined #java
  22. * stewi joined #java
  23. * dob1 joined #java
  24. * jwisbell35 joined #java
  25. * mwnaylor left #java (ERC 5.6.0.30.1 (IRC client for GNU Emacs 30.2))
  26. * johnjay joined #java
  27. * Betal joined #java
  28. * Anaphaxaway joined #java
  29. * GreenResponse joined #java
  30. * metalmaniac joined #java
  31. * jbosmans joined #java
  32. * jamezp joined #java
  33. * hwpplayer1 joined #java
  34. * RootSipher joined #java
  35. * RootSipher left #java (WeeChat 4.9.2)
  36. * enoq joined #java
  37. enoqso I asked about virtual threads (spring) and parallel http requests a couple days ago; turns out by default it's not parallelized (which is what I expected) https://dpaste.com/EXBWBMSAN
  38. enoqwhen I curl the endpoint, it waits for 20s
  39. enoqwhat's the recommended way to deal with that? wrap in CompletableFuture.supplyAsync?
  40. enoq(not 100% sure if that approach loses ThreadLocal context)
  41. enoqthere's also @Async btw
  42. Parahuh, my firewall says dpaste is a dangerous website
  43. enoq~pastebin list options
  44. javabotenoq, what does that even *mean*?
  45. enoq~pastebin
  46. javabotPlease paste your code and any errors online. For runnable classes, try https://ideone.com/ . For general code and errors, use https://gist.github.com or https://dpaste.org/
  47. nevetDiscover gists
  48. enoqdpaste.org is down
  49. enoqhttps://gist.github.com/BernhardPosselt/a5638b26987519fdb60b2fdd414f5443
  50. nevetProductController.kt
  51. ParaSo, it does exactly what it should?
  52. enoqright, I think we had another misunderstanding back then
  53. enoqvirtual threads don't parallelize IO in the same thread
  54. ParaI mean... you've literally written "wait 10 seconds, then wait 10 seconds" :)
  55. enoqsince I'll be aggregating a lot of different rest endpoints, this makes me wonder if I should go reactive and maybe Kotlin coroutines
  56. ParaThat sounds like quite a leap to conclusion. You've written synchronous code, that will not magically turn into asynchronous.
  57. enoqspring.threads.virtual.enabled=true btw
  58. enoqso it will spin off a virtual thread per request
  59. * Cae2 joined #java
  60. enoqso it should be async, just not parallel
  61. ParaYou're solving the wrong problem. You need to change your programming pattern if you want async/parallel execution.
  62. enoqright, so this is how I understand it you could do it using servlet tech https://gist.github.com/BernhardPosselt/a5638b26987519fdb60b2fdd414f5443
  63. nevetProductController.kt
  64. enoqbasically use CompletableFuture.supplyAsync
  65. enoqjust not 100% sure if this makes sense
  66. ParaI don't see how "servlet tech" relates to this at all.
  67. ParaBut yeah, that's what futures are for.
  68. enoqservlet as in: not reactive style
  69. * MikeBux joined #java
  70. dreamrealenoq: did you turn on virtual threads, and you're seeing *subsequent* invocation?
  71. enoqI did turn it on, yes
  72. enoqThread.currentThread().isVirtual() is true
  73. enoqand they're happening one after another
  74. dreamrealokay, so let me make sure what's being described: you have AN ENDPOINT, and you're calling it twice, AND it's executing sequentially such that a 10s call is taking 2(10)s, not 10s twice
  75. dreamrealyou would expect *some* deviation (the time between the "two calls" being started plus a slight deviation for wire transfer time) but those would be pretty small
  76. * jonp` joined #java
  77. enoqI tried to simulate 2 REST endpoints that each take 10s to respond; I want both endpoints to be called in parallel to reduce it from 20s to 10s; later on I'll need to aggregate data from various different services
  78. enoqif I used Thread.sleep() wrong, let me know
  79. dreamrealenoq: You shouldn't see sequential behavior from those servlets *even without* virtual threads
  80. dreamrealsomething else is going on
  81. enoqI'm calling the /testwait endpoint btw
  82. enoqfrom my understanding, Thread.sleep in a virtual thread should suspend, correct?
  83. dreamrealshould suspend THAT THREAD, yes
  84. dreamrealbut even without virtual threads you shouldn't be seeing one-after-the-other execution
  85. dreamrealOH
  86. dreamrealtestwait() is what's blocking, yeah?
  87. enoqyes
  88. dreamrealthose ARE sequential for that thread
  89. dreamrealyou're not executing two calls at the same time
  90. enoqright, that's what I was trying to communicate, we probably talked by each other
  91. dreamrealno worries, I'm in a meeting and attention is spread
  92. dreamrealso this behavior is *correct* for that code
  93. enoqI don't care too much about being able to serve 100k requests at once, I'm more interested in cutting down on sequential async calls
  94. dreamrealyou run one, then you run the other: 10s twice. That's correct and expected.
  95. dreamrealYou're not running those calls at the same time.
  96. dreamrealYour *code* doesn't run them at the same time.
  97. dreamrealcreate a list of completion results, then resolve them.
  98. enoqright, so would you still stick with servlet if that was the main thing your application did and sprinkle in CompletableFutures?
  99. enoqmy guess is that many requests can't be parallel because they'll depend on previous requests, but there might a good chunk that could
  100. dreamrealyeah, you're literally needing to spread out the calls, this is where you actually DO get to multiplex requests
  101. dreamrealIt's not DIFFICULT: create a set of requests and start them, then collect the results
  102. * summerisle joined #java
  103. * ErikT joined #java
  104. * rensenwxre joined #java
  105. * [twisti] joined #java
  106. * tkjay joined #java
  107. * IceMichael joined #java
  108. * chiselfuse joined #java
  109. * braxas joined #java
  110. * leonardus joined #java
  111. * CodeGeek joined #java
  112. * waz joined #java
  113. * kinabalu joined #java
  114. * APic joined #java
  115. * gas51627 joined #java
  116. * ptomli joined #java
  117. * sponkz joined #java
  118. * stfstfm_ joined #java
  119. * metalmaniac joined #java
  120. * hwpplayer1 joined #java
  121. * magla joined #java
  122. * ForeverDreaming joined #java
  123. * Nemu64- joined #java
  124. * Odyss3us joined #java
  125. * Anaphaxaway joined #java
  126. * monkeyPlus joined #java
  127. * ztevoz joined #java
  128. * geli joined #java
  129. * hwpplayer1 joined #java
  130. * sambalala joined #java
  131. sambalala -+\
  132. dreamrealI actually disagree
  133. ernimril^~!
  134. dreamrealno, no, you *!@
  135. dreamrealThou offendsth me
  136. * Ragnor joined #java
  137. * LtHummus joined #java
  138. * five618480339176 joined #java
  139. * lockdown joined #java
  140. * victori joined #java
  141. * hwpplayer1 joined #java
  142. * Anaphaxaway joined #java
  143. * MikeBux joined #java
  144. * mindCrime joined #java
  145. * Maxxed joined #java
  146. * Maxxed joined #java
  147. * sambalala joined #java
  148. * Bharton joined #java
  149. * ForeverDreaming joined #java
  150. * Odyss3us joined #java
  151. * mapperr joined #java
  152. * iwtga7 joined #java
  153. * bionade24 joined #java
  154. NeXeNconcurrency != parallel
  155. NeXeNenoq: and don't fall into the forkjoinpool trap. always lean on your StructuredTaskScope and ExecutorService https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredTaskScope.html and https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/ExecutorService.html btw that's loom docs. don't try and use a spliterator or something or you'll end up waiting 10 seconds blocking
  156. NeXeNthe rest of the world
  157. javabotNeXeN's titles: "StructuredTaskScope (Java SE 25 & JDK 25 [build 1])" | "ExecutorService (Java SE 25 & JDK 25 [build 1])"
  158. nevethttps://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredTaskScope.html "StructuredTaskScope (Java SE 25 & JDK 25 [build 1])" || https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/ExecutorService.html "ExecutorService (Java SE 25 & JDK 25 [build 1])"