Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does it make sense to use QCryptographicHash to generate shorter keys from local URL?
Forum Updated to NodeBB v4.3 + New Features

Does it make sense to use QCryptographicHash to generate shorter keys from local URL?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 519 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi.
    I have modified QQuickFolderListModel to also provide previews of embedded media art.

    It uses QPixmapCache and QNetworkDiskCache for which I currently use the full local URL path as key, but that doesn't seem very efficient, as those strings can get relatively long.

    Does it make sense to use QCryptographicHash to create a 128bit MD5 hash from the path instead in order to speed up key lookup of QPixmapCache and QNetworkDiskCache ?
    Will those benefits (if any) offset the hash computation overhead?

    jsulmJ 1 Reply Last reply
    0
    • DiracsbracketD Diracsbracket

      Hi.
      I have modified QQuickFolderListModel to also provide previews of embedded media art.

      It uses QPixmapCache and QNetworkDiskCache for which I currently use the full local URL path as key, but that doesn't seem very efficient, as those strings can get relatively long.

      Does it make sense to use QCryptographicHash to create a 128bit MD5 hash from the path instead in order to speed up key lookup of QPixmapCache and QNetworkDiskCache ?
      Will those benefits (if any) offset the hash computation overhead?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Diracsbracket said in Does it make sense to use QCryptographicHash to generate shorter keys from local URL?:

      Will those benefits (if any) offset the hash computation overhead?

      I don't think you will gain anything. But you always can try both and compare.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      DiracsbracketD 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Diracsbracket said in Does it make sense to use QCryptographicHash to generate shorter keys from local URL?:

        Will those benefits (if any) offset the hash computation overhead?

        I don't think you will gain anything. But you always can try both and compare.

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #3

        @jsulm
        Thanks for reacting!

        From this post:
        https://stackoverflow.com/questions/22607076/does-stdmapfind-performance-depend-on-the-key-size/22607412
        I got a simple optimization hint to speed up key string comparison operations:
        Instead of using the full path as is, which in the case of a local file system consists of many identical prefixes, I can simply (partially) permute the path string, e.g, if the path is prefix + filename, use instead:

        key = filename + prefix
        

        Or something in that vein.

        jsulmJ 1 Reply Last reply
        0
        • DiracsbracketD Diracsbracket

          @jsulm
          Thanks for reacting!

          From this post:
          https://stackoverflow.com/questions/22607076/does-stdmapfind-performance-depend-on-the-key-size/22607412
          I got a simple optimization hint to speed up key string comparison operations:
          Instead of using the full path as is, which in the case of a local file system consists of many identical prefixes, I can simply (partially) permute the path string, e.g, if the path is prefix + filename, use instead:

          key = filename + prefix
          

          Or something in that vein.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Diracsbracket I'm wondering whether you're over-engineering (or doing premature optimisations)?
          Do you actually experience performance issues?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          DiracsbracketD 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Diracsbracket I'm wondering whether you're over-engineering (or doing premature optimisations)?
            Do you actually experience performance issues?

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by
            #5

            @jsulm said in Does it make sense to use QCryptographicHash to generate shorter keys from local URL?:

            I'm wondering whether you're over-engineering (or doing premature optimisations)?

            You're right, certainly since I'm doing this on a Pi4 with probably a lot more room for optimization. But if anything can be done even a bit more efficiently, then why not. Every little little bit helps.

            Do you actually experience performance issues?

            Well, those performance issues are probably more related to the current disk I/O performance on the Pi, and the fact that my disk cache is still on the micro SD instead of on an external SSD drive...

            Thanks!

            DiracsbracketD 1 Reply Last reply
            0
            • DiracsbracketD Diracsbracket

              @jsulm said in Does it make sense to use QCryptographicHash to generate shorter keys from local URL?:

              I'm wondering whether you're over-engineering (or doing premature optimisations)?

              You're right, certainly since I'm doing this on a Pi4 with probably a lot more room for optimization. But if anything can be done even a bit more efficiently, then why not. Every little little bit helps.

              Do you actually experience performance issues?

              Well, those performance issues are probably more related to the current disk I/O performance on the Pi, and the fact that my disk cache is still on the micro SD instead of on an external SSD drive...

              Thanks!

              DiracsbracketD Offline
              DiracsbracketD Offline
              Diracsbracket
              wrote on last edited by
              #6

              Permuting parts of the path string does not work, unfortunately, since QNetworkDiskCache requires valid URLs...

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved