Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-19074

optimize ec_encode_data with lookup tables to replace gf_mul

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      Claude suggested an optimization while writing some tests for the ec library in Lustre.

      Claude text follows:

      The ec_encode_data() function uses expensive gf_mul() Galois Field 
      multiplication for each byte operation, creating a performance bottleneck 
      for erasure coding operations.

      Problem:

      • gf_mul() performs O(log n) computation using logarithm tables
      • High CPU overhead for erasure coding operations

      Solution:
      Replace gf_mul() with fast O(1) lookup table operations:

      • Split bytes into 4-bit nibbles (upper and lower)
      • Use pre-computed lookup tables in the 'v' array
      • XOR nibble results: coeff = v[offset + lower] ^ v[offset + 16 + upper]
      • Leverage existing gf_vect_mul_init() infrastructure

      Benefits:

      • 15-25% performance improvement across all EC configurations
      • Better CPU cache utilization with 4-bit lookups
      • Maintains full API compatibility

      Testing shows consistent improvements:

      • 4KB blocks: 1.20x speedup, 395→476 MB/s throughput
      • 1MB blocks: 1.18x speedup, 381→450 MB/s throughput  
      • Best case (6+3 EC): 1.32x speedup, 242→320 MB/s throughput

      Particularly beneficial for high-frequency operations and complex 
      erasure coding configurations.

      Attachments

        Activity

          [LU-19074] optimize ec_encode_data with lookup tables to replace gf_mul
          adilger Andreas Dilger added a comment - - edited

          We shouldn't be optimizing the EC calculations yet, for two reasons:

          1. we don't have working code yet, so faster both working code doesn't help us
          2. there is optimized ASM code for x86 and ARM CPUs in the BSD ISA-L library, we just haven't included them into the code yet, because the C implementation was more portable and sufficient during development.
          adilger Andreas Dilger added a comment - - edited We shouldn't be optimizing the EC calculations yet, for two reasons: we don't have working code yet, so faster both working code doesn't help us there is optimized ASM code for x86 and ARM CPUs in the BSD ISA-L library, we just haven't included them into the code yet, because the C implementation was more portable and sufficient during development.

          "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59501
          Subject: LU-19074 ec: add loop unrolling for common source counts
          Project: fs/lustre-release
          Branch: master
          Current Patch Set: 1
          Commit: afb9557a1e89231b48fa316635974a2ebed2ccbd

          gerrit Gerrit Updater added a comment - "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59501 Subject: LU-19074 ec: add loop unrolling for common source counts Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: afb9557a1e89231b48fa316635974a2ebed2ccbd

          "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59500
          Subject: LU-19074 ec: optimize ec_encode_data addressing overhead
          Project: fs/lustre-release
          Branch: master
          Current Patch Set: 1
          Commit: 947b38fbb8a78d1b9e26fa78419739d4e1f2fa4f

          gerrit Gerrit Updater added a comment - "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59500 Subject: LU-19074 ec: optimize ec_encode_data addressing overhead Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 947b38fbb8a78d1b9e26fa78419739d4e1f2fa4f

          "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59485
          Subject: LU-19074 ec: Add EC library sanity test to test suite
          Project: fs/lustre-release
          Branch: master
          Current Patch Set: 1
          Commit: 18705d18166dbcb9db6d5dc18c04e81d6b6447b8

          gerrit Gerrit Updater added a comment - "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59485 Subject: LU-19074 ec: Add EC library sanity test to test suite Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 18705d18166dbcb9db6d5dc18c04e81d6b6447b8

          "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59484
          Subject: LU-19074 ec: optimize encode with lookup tables
          Project: fs/lustre-release
          Branch: master
          Current Patch Set: 1
          Commit: 708a35016550cea906bdaaec2ed3eb7ccebe75b2

          gerrit Gerrit Updater added a comment - "Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/59484 Subject: LU-19074 ec: optimize encode with lookup tables Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 708a35016550cea906bdaaec2ed3eb7ccebe75b2

          People

            paf0186 Patrick Farrell
            paf0186 Patrick Farrell
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: