Skip to content

Avoid repeated Incar.get() calls which slow down vasprun parsing by ~20-50%#4359

Merged
shyuep merged 1 commit intomaterialsproject:masterfrom
kavanase:vasprun_parsing_speedup
Apr 15, 2025
Merged

Avoid repeated Incar.get() calls which slow down vasprun parsing by ~20-50%#4359
shyuep merged 1 commit intomaterialsproject:masterfrom
kavanase:vasprun_parsing_speedup

Conversation

@kavanase
Copy link
Copy Markdown
Contributor

From profiling my Vasprun initialisations, I found that one of the main contributions to runtime was repeated Incar.get() calls:

def get(self, key: str, default: Any = None) -> Any:

This can be slow when called many times because of the UserDict.get() implementation from collections.abc and formatting code. Because incar.get("ML_LMFF") was being used in the Vasprun parsing loop, this method was called e.g. 1e4 - 1e6+ times in my vasprun parsing. Changing this so that incar.get("ML_LMFF") is only called once to determine if the vasp run is an ML run, means incar.get only gets called ~20 times and reduces the vasprun parsing time by ~20-50% (depending on choices of parse_dos and parse_projected_eigen).

@shyuep shyuep merged commit a031297 into materialsproject:master Apr 15, 2025
42 checks passed
@shyuep
Copy link
Copy Markdown
Member

shyuep commented Apr 15, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants