Skip to content

Conversation

@circuitmuggle
Copy link
Contributor

… x37 faster tran.tran.tran file reading without cache file
original read speed of 3.6GB file
image
optimized read speed of the same 3.6GB file (rm tran.tran.tran.cache before test)
image

compatible with original flow, optimized with

  1. Bulk File Reading (I/O Optimization), Reads the entire file content into memory at once using f.read()
  2. Vectorized Parsing (CPU Optimization), Uses numpy to convert the entire array of string tokens to floats in a single C-level operation (np.array(tokens, dtype=float))
  3. Simplified "Fast Path" Logic. Original uses a complex, robust parser (likely ply based) that handles every possible edge case and syntax variation, which is computationally expensive.Implemented a _try_fast_read method that assumes the VALUE section (where the heavy data lives) has a regular structure. It directly splits the string and reshapes the array, bypassing the complex parsing logic for the bulk of the data.
  4. Hybrid Compatibility, The code now attempts the Fast Path first. If the file structure is complex (e.g., DC operating points or non-standard formats) or if the fast read fails for any reason, it automatically falls back to the original parser.

… x37 faster tran.tran.tran file reading without cache file
@KenKundert
Copy link
Owner

A remarkable idea. Thanks! But it seems that it is failing the tests: the sweep units were not picked up.

…nd Type sections (which are small and fast to parse). This ensures all metadata is correct.Use the Fast Reader ONLY for the VALUE section (which is huge and slow to parse in Python).This fix tox test like pss_td, joop_banana_tran, dan_zilla, empty. Add special fix to handle GROUP in Trace in file rushikesh-dhanaji-phadtare.tran, roll back to origianl parser if GROUPs are present
@circuitmuggle
Copy link
Contributor Author

circuitmuggle commented Nov 30, 2025

Hi Ken, I modify the code based on the tox tests feedback. It now shows pass the tests. But let me know if I missed something else.

@KenKundert KenKundert merged commit f4fd302 into KenKundert:master Dec 1, 2025
3 checks passed
@KenKundert
Copy link
Owner

I'll let it age for a bit before releasing it to pypi.

It is a very nice enhancement. Thanks!

KenKundert added a commit that referenced this pull request Dec 4, 2025
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