Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_zlib: test_pair() and test_speech128() fail with s390x hardware accelerator #90781

Closed
vstinner opened this issue Feb 3, 2022 · 7 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

vstinner commented Feb 3, 2022

BPO 46623
Nosy @vstinner, @encukou
PRs
  • bpo-46623: Skip two test_zlib tests on s390x #31096
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-03.08:34:40.152>
    labels = ['tests', '3.9', '3.10', '3.11']
    title = 'test_zlib: test_pair() and test_speech128() fail with s390x hardware accelerator'
    updated_at = <Date 2022-03-03.13:20:48.694>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2022-03-03.13:20:48.694>
    actor = 'petr.viktorin'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2022-02-03.08:34:40.152>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46623
    keywords = ['patch']
    message_count = 6.0
    messages = ['412426', '413866', '413939', '413940', '413941', '414437']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'petr.viktorin']
    pr_nums = ['31096']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46623'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 3, 2022

    test_pair() and test_speech128() tests of test_zlib fail on the s390x architecture if zlib uses the s390x hardware accelerator.

    RHEL8 downstream issues (with most details):
    https://bugzilla.redhat.com/show_bug.cgi?id=1974658

    Fedora downstream issues:
    https://bugzilla.redhat.com/show_bug.cgi?id=2038848

    The s390x has a hardware accelerator for zlib. Depending if the hardware accelerator is used or not, the output (compress data) is different.

    Also, test_zlib compress data in two different ways and then expect the same output. test_zlib pass with the software implementation which creates a single (final) compressed block. test_zlib fails with the hardware implementation which creates multiple compressed blocks (the last one is a final block).

    Another reason the output differs is the FHT/DHT heuristic. The zlib deflate algorithm can analyze the data distribution and decide whether it wants to use a fixed-Huffman table (FHT) or a dynamic-Huffman table (DHT) for the next block, but the accelerator can't. Furthermore, looking at data in software would kill the accelerator performance. Therefore the following heuristic is used on s390x: the first 4k are compressed with FHT and the rest of the data with DHT. So, compress() creates a single FHT block. compressobj() creates a FHT block, a DHT block and a trailing block.

    It is *not a bug* in zlib: the decompression gives back the original content as expected in all cases. The issue is that Python test_zlib makes too many assumptions on how "streamed" data should be compressed. The test expected that compressed data using different ways to call zlib would return the exact same compressed data. If an accelarator is used, it's not always the case.

    @vstinner vstinner added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir labels Feb 3, 2022
    @vstinner
    Copy link
    Member Author

    I checked os.uname() value on two buildbots, by looking at their test.pythoninfo:

    os.uname: posix.uname_result(sysname='Linux', nodename='ztcpip3.pok.ibm.com', release='3.10.0-1160.53.1.el7.s390x', version='#1 SMP Thu Dec 16 04:33:52 EST 2021', machine='s390x')

    os.uname: posix.uname_result(sysname='Linux', nodename='dje', release='5.10.0-11-s390x', version='#1 SMP Debian 5.10.92-1 (2022-01-18)', machine='s390x')

    So the machine is 's390x'.

    @vstinner
    Copy link
    Member Author

    New changeset 9475dc0 by Victor Stinner in branch 'main':
    bpo-46623: Skip two test_zlib tests on s390x (GH-31096)
    9475dc0

    @vstinner
    Copy link
    Member Author

    Even if Python 3.9 and 3.10 are also affected, I prefer to not backport the change since it's not ideal.

    @vstinner
    Copy link
    Member Author

    The Python 3.7 package on Fedora also skips these two tests using --ignore option of regrtest:

    %ifarch s390x
    --ignore test_speech128 \\
    --ignore test_pair \\
    %endif
    

    @encukou
    Copy link
    Member

    encukou commented Mar 3, 2022

    The current fix skips all of the tests, rather than just the parts that fail.

    @encukou encukou reopened this Mar 3, 2022
    @encukou encukou reopened this Mar 3, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @vstinner
    Copy link
    Member Author

    vstinner commented Nov 3, 2022

    The current fix skips all of the tests, rather than just the parts that fail.

    Right. In short, I copied the Fedora fix to Python as 9475dc0 because I know that it works on s390x.

    But I don't have access to a s390x machine with hardware accelerator, so I cannot develop a change which only skips the tests if hardware accelerator is present, or only skip the part which is affected by the hardware accelerator.

    test_zlib: test_pair() and test_speech128() fail with s390x hardware accelerator

    The initial scope of the issue is fixed, so I just close the issue.

    If you manage to write and test a better fix, please open a separated issue/PR.

    @vstinner vstinner closed this as completed Nov 3, 2022
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 3, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl added a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl pushed a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl pushed a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    mcepl pushed a commit to openSUSE-Python/cpython that referenced this issue Apr 4, 2024
    Skip test_pair() and test_speech128() of test_zlib on s390x since
    they fail if zlib uses the s390x hardware accelerator.
    
    Code is originally from gh#python/cpython!31096, it was released
    upstream in 3.11.0.
    
    Fixes: gh#python#90781
    Fixes: bpo-46623
    Patch: bpo-46623-skip-zlib-s390x.patch
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir
    Projects
    Status: Done
    Development

    No branches or pull requests

    2 participants