![]() The biggest cumulative time (4.4 ms) is the encodings package, plus another 1.7 ms for two specific encodings. Import time: 1105 | 1105 | encodings.aliases Import time: 708 | 1114 | _frozen_importlib_external Import time: self | cumulative | imported package # code object from '/home/mark/repos/cpython/Lib/_pycache_/' # /home/mark/repos/cpython/Lib/_pycache_/ matches /home/mark/repos/cpython/Lib/abc.py # code object from '/home/mark/repos/cpython/Lib/_pycache_/io.cpython-310.pyc' # /home/mark/repos/cpython/Lib/_pycache_/io.cpython-310.pyc matches /home/mark/repos/cpython/Lib/io.py # code object from '/home/mark/repos/cpython/Lib/encodings/_pycache_/utf_8.cpython-310.pyc' # /home/mark/repos/cpython/Lib/encodings/_pycache_/utf_8.cpython-310.pyc matches /home/mark/repos/cpython/Lib/encodings/utf_8.py # code object from '/home/mark/repos/cpython/Lib/encodings/_pycache_/' # /home/mark/repos/cpython/Lib/encodings/_pycache_/ matches /home/mark/repos/cpython/Lib/encodings/aliases.py # /home/mark/repos/cpython/Lib/_pycache_/ matches /home/mark/repos/cpython/Lib/codecs.py # code object from '/home/mark/repos/cpython/Lib/encodings/_pycache_/_init_.cpython-310.pyc' # /home/mark/repos/cpython/Lib/encodings/_pycache_/_init_.cpython-310.pyc matches /home/mark/repos/cpython/Lib/encodings/_init_.py For the interpreter, the data structure needs to mark offsets so we can tell which are pointers into the runtime, and which are pointers into the interpreter. For the runtime (static objects) there is no need for offsets, just create the graph with pointers. Since they are not, at least not yet, we need to break the object graph into the part belonging to the runtime, and that belonging to each interpreter. The above assumes that interpreters are fully independent. Traversing the offsets of offsets, converting them into pointers.Copying the static structure into the newly allocated memory for the interpreter.We can now create the entire object graph for the interpreter by: A table containing offsets of those offsets. ![]() A static structure containing the whole object graph, with offsets not pointers.Make a tool that generates two pieces of C code:.Discard the modified CPython, we shouldn't need it anymore.Check in that spec, we will want to modify it later, and it will probably need fixing up by hand.Convert that text file into a declarative spec of the initial object graph.Modify CPython to walk the object graph, immediately after interpreter creation, dumping it to a text file.If creating and/or destroying the new interpreter is what takes the time, then one possible way to speed it up is to freeze the object graph of a newly created interpreter.
0 Comments
Leave a Reply. |