Skip to content

Unexpectedly Poor Performance on AMD Ryzen 9 7950X? #61

@JohnTravolski

Description

@JohnTravolski

I benchmarked a variety of Python operations between an i7 5960x (released late 2014) and an AMD Ryzen 9 7950X (released late 2022). In general, the single threaded performance of the 7950X is typically much higher than the 5960X given the improvements that have been made during that timeframe. However, I noticed that xxhash doesn't see the same speedup. Here's a comparison of a variety of Python functions and the time they took to run on both machines (Python 3.8, xxhash==1.4.3):

image

The 3rd and 4th column are the time in seconds for each machine to run each operation a given number of times, either measured with time.time() or time.perf_counter().

The code for measuring the performance of xxhash was as follows:

import xxhash
import time

hard = 10
datadict = {}

def timer(num_attempts = 10):
  def decor(func):
    def wrapper(*args):
      for timefunc, string in [(time.time, "time()"), (time.perf_counter, "perf_counter()")]:
        times = []
        for attempt_num in range(num_attempts):
          start = timefunc() # start counting time using the given timing function
          result = func(*args) # the code we're benchmarking
          end = timefunc()
          duration = end - start
          times.append(duration)
        average_time = sum(times)/len(times) # take the average of the times over num_attempts
        datadict[func.__name__ + "~" + string] = average_time
      return result
    return wrapper
  return decor

@timer(hard)
def xxhash_4kimg_5ktimes(filebits):
  j = 0
  for i in range(5000):
    j = xxhash.xxh64(filebits).hexdigest()
  return j
  
print("Timing hashing")
with open('2.jpg', 'rb') as afile:
  filebits = afile.read()
print("\txxhash:")
j = xxhash_4kimg_5ktimes(filebits)

for key, val in datadict:
  print(key, val)

('2.jpg' is a 2.94 MB jpeg file, 3840x2160 resolution). I'm on Windows 10.

Any idea why the speedup isn't higher, as many of the other functions I tested were? On average I was getting at least a 2x speedup for most Python functions, but only got 1.08x for xxhash. It was the only one that performed so poorly.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions