Skip to content

perf: cache fully built data types in buildDataType()#178

Merged
jisotalo merged 1 commit intojisotalo:devfrom
crishoj:cache-built-data-types
Dec 27, 2025
Merged

perf: cache fully built data types in buildDataType()#178
jisotalo merged 1 commit intojisotalo:devfrom
crishoj:cache-built-data-types

Conversation

@crishoj
Copy link
Contributor

@crishoj crishoj commented Dec 9, 2025

buildDataType() method is recursively rebuilding the full type hierarchy on every call, even though the underlying getDataTypeDeclaration() results are cached.

This can cause significant CPU overhead with frequent ADS notifications.

This change adds a cache for the fully built data types (builtDataTypes), similar to the existing plcDataTypes cache:

  • keyed by lowercase type name (matching existing convention)
  • only caches root types (not intermediate recursive calls)
  • respects the disableCaching setting
  • is cleared when the PLC symbol version changes

@jisotalo
Copy link
Owner

Thanks @crishoj, I'll try to check this through during holidays!

@jisotalo jisotalo changed the base branch from master to dev December 27, 2025 06:29
@jisotalo jisotalo merged commit bc9275b into jisotalo:dev Dec 27, 2025
jisotalo added a commit that referenced this pull request Dec 27, 2025
### Added
- Added caching of built data types to improve performance
  - See [pull request #178](#178)

### Changed
- Bug fix: Unhandled Promise rejections during automatic reconnecting
  - See [pull request #177](#177)
- Fixed a Typescript warning at `socket.on("data", (data) => {...})` as the data chunk could be a string as well
- Dependencies updated
- Documentation updated
@jisotalo jisotalo mentioned this pull request Dec 27, 2025
jisotalo added a commit that referenced this pull request Dec 27, 2025
## [2.2.0] - 27.12.2025
### Added
- Added caching of built data types to improve performance
  - See [pull request #178](#178)
  
### Changed
- Bug fix: Unhandled Promise rejections during automatic reconnecting
  - See [pull request #177](#177)
- Fixed a Typescript warning at `socket.on("data", (data) => {...})` as the data chunk could be a string as well
- Dependencies updated
- Documentation updated

Thank you [Christian Rishøj](https://github.com/crishoj) for contribution!

All tests passing.
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