Skip to content

[ENH]: Support parallel plotting #30420

@neutronst4r

Description

@neutronst4r

Problem

When plotting multiple plots at once, matplotlib will sometimes nondeterministically fail, when plt.rcParams["text.usetex"] = True is used. A cache directory is created in the MPLCONFIGDIR, which is used globally. Cache files are created with random file names and if independent processes create or delete them, while one tries to access them, matplotlib will fail.

There was a workaround by resetting the MPLCONFIGDIR variable and then reloading matplotlib, but that solution has its own problems now.

Proposed solution

Two solutions come to mind:

  1. make it possible to change the location of the cache dir after matplotlib was imported, this would require a user to know to change it, if they want to plot in parallel.
  2. Remove the conflict by making the cache files unique globally, for example by numbering them sequentially or adding the process id of the owning process.

I would also like to add, that a significant boost in execution speed can be achieved, if the cache dir is created in RAM instead of flash or hard disk memory. See this example here. Perhaps it would be wise to also move the cache dir to /tmp if it exists on a given system.

The most sensible thing to do imho, would be to move the cache dir to a place where it cannot interfere with any other process, meaning solution 2. And that location should be a RAM disk, if available.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions