ericsnowcurrently / multi-core-python

Enabling CPython multi-core parallelism via subinterpreters.
BSD 3-Clause "New" or "Revised" License
245 stars 6 forks source link

Critical deficiencies in `Tools/c-globals/check-c-globals.py`. #47

Open ericsnowcurrently opened 5 years ago

ericsnowcurrently commented 5 years ago

(see #33)

The existing Tools/c-globals/check-c-globals.py script is an important tool for achieving a per-interpreter GIL (and generally for the health of the CPython code base). However, it has a number of problems that keep it from being helpful in reaching that objective.

First we'll review the characteristics of the tool. Then we'll look at the deficiencies. Finally, we'll cover the specific tasks that will address those problems.

Purpose

The script has the following 2 core purposes:

(More or less, "unsupported" means the variable holds per-interpreter runtime state.)

Constraints

The script also has the following core constraints:

Deficiencies

In context of those purposes and constraints, the script has some critical deficiencies (in rough order of priority):

(Note that non-critical deficiencies (and nice-to-haves) are covered in #49.)

Solution

(Reminder: we're only aiming to addresss critical deficiencies here.)

High-level Plan

At that point we can use the tool sans nearly all deficiencies. The remaining tasks would then be:

Directory Structure

Tools/c-analyzer/
    c_statics/
        README (including "Resolving Failures" section)
        __main__.py
        find.py
        show.py
        known.py
        supported.py
        ignored.tsv (temporary)
    c_parser/
        files.py
        info.py
        statics.py
        declarations.py
    c-statics.py
    check-c-statics.py
Lib/test/
    test_tools/test_tool_c_analyzer/
        testdata/...
        test_c_statics/...
        test_c_parser/...
    test_check_c_statics.py

c-statics.py CLI

The c-statics.py script will initially have the following basic CLI:

Specific Tasks for c-globals.py

(Each task includes adding sufficient tests.)

System Tests

  1. "self-check":
    • run normal check
    • ensure known macros & vartypes aren't hiding unknown local types
    • compare results with nm output
  2. run c-globals.py show against dummy files
    • check exact output
    • drive results via "known" and "ignored" files
    • static vars are a mix of POTS, stdlib, 3rd-party, and local types
    • no known macros or vartypes unless otherwise indicated
    • tests (none ignored):
      • all known -> supported
      • only local known -> supported
      • some local unknown -> unsupported
      • some vartypes known but not their nested local type -> supported (fail self-check?)
      • some macros known but not their nested local type -> supported (fail self-check?)
  3. run c-globals.py check against dummy files:
    • make sure a passing "check" really means everything is okay
    • ...

dummy files: