Solving Java Multithreading Challenges in My Google Photos Clone

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ธ.ค. 2024

ความคิดเห็น • 32

  • @KolosBros
    @KolosBros ปีที่แล้ว +12

    Marco, has anyone ever told You that You're doing absolutely fantastic stuff? Because You're doing absolutely amazing stuff

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว +1

      Jacek, thanks a lot for those words!! Much appreciated and a great start for the day for me.

  • @stephentomaszewski8501
    @stephentomaszewski8501 ปีที่แล้ว +4

    Please do a deep dive into optimizing the mutiprocessing. Most people don't understand the difference between threads and processes and how threads are light weight processes that share data, code, and the heap but have their own stack which makes context switching quicker.

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว

      Will see how/when to fit this in!

  • @tipazas
    @tipazas ปีที่แล้ว +1

    No need to say we want some content or not, from you it's interesting to see about everything :)

  • @marcinkunert
    @marcinkunert ปีที่แล้ว +2

    Awesome content as always. Thanks Marco!

  • @SergiyPonomarenko-f5e
    @SergiyPonomarenko-f5e ปีที่แล้ว +2

    Great as always!

  • @fmictsang8874
    @fmictsang8874 10 หลายเดือนก่อน

    I learn a lot from this video.

  • @igeolasoji3513
    @igeolasoji3513 ปีที่แล้ว +1

    Hello Marco,
    I believe calling the parallel method before the other operators should work with the old Java version.

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว +1

      Hey Ige, nope, the order has no effect. As mentioned, it was a long known issue in the JDK, I'll need to dig around and find the openjdk bug report for this one.

  • @vishnugovindan8550
    @vishnugovindan8550 ปีที่แล้ว

    Hi Marco, any good resources on concurrent/multi threading programming in Java apart from concurrency in practice that you have found helpful?

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว +1

      Concurrency in practice is literally it. It's a bummer that there is no new version out, but reading/working through it will give you the best base possible.
      You also might want to follow up with the "little book of semaphores"

  • @cdhagen
    @cdhagen ปีที่แล้ว

    16:25 Would be interesting to see how you solve the potential race condition when two threads work on identical files. I'm thinking about some kind of synchronized Set which stores the hashes of already processed images, maybe? 🤔

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว +2

      There are many ways to approach this. The easiest one I could think of for now is to let the two threads work on identical files, but render the resulting thumbnail to a randomly named tmpfile. And after rendering has finished, "mv" the tmp file into the final destination. If some other thread has already created the final file, then the mv will just be ignored, the file deleted and that's it. It's a simple solution without elaborated synchronisation on the Java side, just a bit of additional CPU wasted in this corner case.

  • @rydmerlin
    @rydmerlin ปีที่แล้ว

    If ImageMagick was multithreaded would you want to see it using its own thread pool? Also can you say which NAS that you’re running Java on?

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว

      ImageMagick in fact already is multithreaded, and you can influence that behavior with command line options. Explaining what effect that has is a whole other topic :) as for the Nas, it is self-assembled and I don't quite remember the individual parts - it has been a couple years.

  • @tipazas
    @tipazas ปีที่แล้ว

    Just interested... what is the rationale behind strictly not using old File API? Performance? For me it looks like big price to have so much technical code copied instead of calling hasher.update(image.toFile()). Thank you.

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว +1

      That is a good question. It is just from past experience that I've seen the file API becoming cumbersome at some point, e.g. testing. And I got into the habit of making sure to use the Path API whenever I can - but sure, for the scope of that prototype we could have also used the "old" file API.

  • @AmNotLegend
    @AmNotLegend ปีที่แล้ว

    combine two filter in a private method

  • @alirezaasadi8656
    @alirezaasadi8656 8 หลายเดือนก่อน

    nothing new , most important question were not answered. you ask questions we are here for answers.
    that is actually a bad thing. we are here looking for the answers not questions. question already raised by ourselves.

    • @MarcoCodes
      @MarcoCodes  8 หลายเดือนก่อน

      Ironically your nonsensical comment contains not a single question.

    • @marin1419
      @marin1419 7 หลายเดือนก่อน

      @@MarcoCodes His prose follows the style of Gottlob Frege lmao

  • @cypherliquid
    @cypherliquid ปีที่แล้ว

    you are not going to continue this google photos clone

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว

      Why?

    • @cypherliquid
      @cypherliquid ปีที่แล้ว

      @@MarcoCodes common its 1st April you can't fall for this

    • @MarcoCodes
      @MarcoCodes  ปีที่แล้ว

      I DID! :D Good one!