Page MenuHomePhabricator

Investigate performance of Python implementations where there is an argument containing an explicitly typed list
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
GrounderUK
Apr 9 2025, 8:40 AM
Referenced Files
F59111876: IMG_1225.jpeg
Apr 15 2025, 9:43 AM
F59023002: IMG_1219.png
Apr 9 2025, 8:40 AM
F59023010: IMG_1217.png
Apr 9 2025, 8:40 AM
F59022914: IMG_1216.png
Apr 9 2025, 8:40 AM

Description

The performance of Python implementations has quite recently taken a huge stride backwards, where there is an argument containing an explicitly typed list of objects.

For example, see https://www.wikifunctions.org/view/en/Z18290

  • The cached result for Z18289 is from January
    IMG_1216.png (960×2,079 px, 164 KB)
    .
  • Editing this test case now produces a timeout
    IMG_1217.png (960×2,079 px, 175 KB)
  • Using Try this implementation with empty lists also times out
    IMG_1219.png (960×2,079 px, 167 KB)

This is just an example. I first noticed this when looking at https://www.wikifunctions.org/view/en/Z12863, where there are now failing tests that previously passed. Looking at WikiLambda system’s activity in the function history, it looks like the problem might have begun between the 23rd and 26th March https://www.wikifunctions.org/w/index.php?title=Z12696&diff=175761&oldid=175013

(Previously mentioned on https://t.me/Wikifunctions/24408)

Event Timeline

I have now experienced issues with JavaScript. A new function, Z23772, simply requires its input list of integers (from Natural numbers) to be returned (and converted to Integers). The JavaScript implementation fails with a list of seven ints (Z23777). With six ints, it passed in 743 ms (67 ms Evaluation), CPU usage 286.1.

An equivalent Python implementation succeeds with one int 6720 ms (5842 ms Evaluation), CPU usage 370.7. It fails with two ints 9798 ms (9014 ms Evaluation) CPU usage 577.5.

https://www.wikifunctions.org/view/en/Z23772

GrounderUK changed the subtype of this task from "Task" to "Production Error".Apr 15 2025, 8:34 AM

Z20086 is a good example for Rational numbers: failing if the list is not empty. I think we should consider this a Production Error.

Jdforrester-WMF changed the subtype of this task from "Production Error" to "Bug Report".Apr 16 2025, 3:54 PM
Jdforrester-WMF subscribed.

This is not what "Production Error" is for, so moving over to be a regular task.

Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald TranscriptApr 16 2025, 3:54 PM

This is not what "Production Error" is for, so moving over to be a regular task.

Whatever… It may be P2 rather than P1, since it is limited to Python, but an inability to echo a list containing even a single item of some important types certainly feels like a production error. I did seek guidance when I raised the ticket but none was forthcoming.

This is not what "Production Error" is for, so moving over to be a regular task.

Whatever… It may be P2 rather than P1, since it is limited to Python, but an inability to echo a list containing even a single item of some important types certainly feels like a production error. I did seek guidance when I raised the ticket but none was forthcoming.

Who do you think would answer you in Telegram? The engineers generally aren't there, unlike Phabricator or the project chat. Seeing this task during the weekly triage was the first I ever heard of this. If you want us to see it sooner, as we have said before, please post it so we can respond rapidly.

Jdforrester-WMF changed the subtype of this task from "Production Error" to "Bug Report".Apr 17 2025, 1:28 PM

Obviously I raised it here on April 9th. I don’t know how one is supposed to prioritise triage when raising a ticket but https://www.wikifunctions.org/wiki/Wikifunctions:Report_a_technical_problem#Discuss_with_others specifically refers to Telegram.

It seems like this problem may be associated with particular Types within Typed lists.

see https://www.wikifunctions.org/view/en/Z24212 where the test on natural languages works but a similar test on natural numbers doesn't.

Please could someone look at this as a matter of priority, just to determine whether it is a problem that only affects Production and whether it’s P1 or P2? Thanks!

The different underlying issues are being addressed in different phab tasks:
T393130: handle large log response: some fixes merged, but more to come
T392905: invalid result validation in one test causes indefinite "running" in all others: fixed and merged
T393152: Service utils logger fails with message containing stack trace: service-utils related issue, related fix is merged

Just noting that Typed pairs may have a similar issue in Python. We don't use them much, but https://www.wikifunctions.org/view/en/Z24645 works in Javascript (2163 ms), but fails in Python.

gengh removed gengh as the assignee of this task.May 17 2025, 9:59 PM
gengh subscribed.

As far as I can tell, all the specific issues reported here have been resolved. Many thanks to everyone involved.

I am happy for this to be closed.

DSantamaria changed the task status from Open to In Progress.May 29 2025, 5:15 AM

It seems like this problem may be associated with particular Types within Typed lists.

see https://www.wikifunctions.org/view/en/Z24212 where the test on natural languages works but a similar test on natural numbers doesn't.

This still seems to be a problem.

Thanks @99of9
It seems we need to continue investigating this issue.
Agreed: It appears to happen only on typed lists of particular types.

Observed only in the python implementation:

Happening in all implementations (not sure if it's the same issue):

Function: Discard tail of Typed list after first match/Z24203

Error 1: Typed List of Natural Number
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z24203&wikilambda_perform_test_zimplementations=Z24212&wikilambda_perform_test_ztesters=Z24205&uselang=en

  • function: Z24203
  • implementation: Z24212 (python)
  • tester: Z24205

first function call returns error:

{
    "Z1K1": "Z5",
    "Z5K1": "Z500",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z500"
        },
        "Z500K1": "Could not serialize input Python object: 0"
    }
}

Error 2: Typed List of Rational number
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z24203&wikilambda_perform_test_zimplementations=Z24212&wikilambda_perform_test_ztesters=Z24319&uselang=en

  • function: Z24203
  • implementation: Z24212 (python)
  • tester: Z24319

first function call returns error:

{
    "Z1K1": "Z5",
    "Z5K1": "Z500",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z500"
        },
        "Z500K1": "Could not serialize input Python object: Fraction(1, 2)"
    }
}

Error 3: Typed List of Gregorian calendar month
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z24203&wikilambda_perform_test_zimplementations=Z24212&wikilambda_perform_test_ztesters=Z24320&uselang=en

  • function: Z24203
  • implementation: Z24212 (python)
  • tester: Z24320

first function call returns error:

{
    "Z1K1": "Z5",
    "Z5K1": "Z500",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z500"
        },
        "Z500K1": "Could not serialize input Python object: 1"
    }
}

Function: Concatenate two untyped lists/Z12767

Error 1: Join Typed lists of Integers (python)
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z12767&wikilambda_perform_test_zimplementations=Z12792&wikilambda_perform_test_ztesters=Z18622&uselang=en

function: Z12767
implementation: Z12792 (python)
test: Z18622

{
    "Z1K1": "Z5",
    "Z5K1": "Z507",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z507"
        },
        "Z507K1": "'ZObject' object can't be concatenated"
    }
}

Error 2: Join Typed lists of Integers (javascript)
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z12767&wikilambda_perform_test_zimplementations=Z18614&wikilambda_perform_test_ztesters=Z18622&uselang=en

function: Z12767
implementation: Z18614 (javascript)
test: Z18622

{
    "Z1K1": "Z5",
    "Z5K1": "Z500",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z500"
        },
        "Z500K1": "not a function"
    }
}

Error 3: Join Typed lists of Integers (composition)
/w/api.php?action=wikilambda_perform_test&format=json&wikilambda_perform_test_zfunction=Z12767&wikilambda_perform_test_zimplementations=Z13231&wikilambda_perform_test_ztesters=Z18622&uselang=en

function: Z12767
implementation: Z13231 (composition)
test: Z18622

{
    "Z1K1": "Z5",
    "Z5K1": "Z500",
    "Z5K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z885",
            "Z885K1": "Z500"
        },
        "Z500K1": "not a function"
    }
}
DSantamaria changed the task status from In Progress to Open.Jun 5 2025, 3:27 PM

Hello, all! There are two issues here. One is our current treatment of types in the orchestrator -> evaluator request, which should be fixed as of next deploy (currently blocked, unfortunately).

The other issue is that type conversion won't work when the list declares its type as Z1. To overcome this issue, list arguments can be wrapped in Z18475/Return typed list. This issue is discussed at length in this task.

I’m inclined to consider this problem beautifully resolved. Am I missing something?

Hello, all! There are two issues here. One is our current treatment of types in the orchestrator -> evaluator request, which should be fixed as of next deploy (currently blocked, unfortunately).

The other issue is that type conversion won't work when the list declares its type as Z1. To overcome this issue, list arguments can be wrapped in Z18475/Return typed list. This issue is discussed at length in this task.

cmassaro claimed this task.

Cool! Closing.