Skip to content

Daemon mode to speed up startup? #90

Closed

Description

@gvanrossum

One idea that I've heard a few times is a "daemon" mode where there's a server that can execute general Python requests, and a tiny client that just passes arguments to the server. There are lots of problems with this (e.g. dribbling stdout/stderr, tty access, etc.) and it's probably better done as a 3rd party package that certain apps can use. Does anyone know of a general solution like this? (Mypy has a daemon mode that works like this, but the client is still a Python script, so it wouldn't help startup time.)

Activity

  1. markshannon commented on Sep 30, 2021

    @markshannon
    Member

    For this to work the daemon would need to have a pool of VMs that have already started and are ready to execute arbitrary Python code. This implies that a significant amount of time is spent readying the VM before it can start executing. If that is the case, then we should implement some sort of snapshot of an initialized VM #32 (comment)

    The difference between the daemon and the snapshot at startup would most likely be insignificant.
    If Python is executed frequently, the snapshotted executable will be in the O/S disk cache and loading it will be fast.
    If Python is executed infrequently, then the in-memory VM held by the daemon is likely to have been paged out and will be as slow of the snapshotted executable.

  2. gvanrossum commented on Sep 30, 2021

    @gvanrossum
    CollaboratorAuthor

    The daemon could presumably pre-fork a bunch of processes after importing a bunch of popular modules, a la Instagram (at least on UNIX). Then no snapshot feature would be required. (Not sure what to do for Windows.)

  3. markshannon commented on Oct 4, 2021

    @markshannon
    Member

    My point was that he daemon process offers no performance advantages over the snapshot approach, but is less portable.

    I suspect which is simpler to implement depends on your skill set. Personally, I would find the snapshot approach easier to implement.

  4. gvanrossum commented on Oct 4, 2021

    @gvanrossum
    CollaboratorAuthor

    Maybe snapshots can be implemented using the approach from the Alibaba Compiler team (#86).

  5. locked and limited conversation to collaborators on Dec 2, 2021
  6. moved this from Todo to Other in Fancy CPython Boardon Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions