[PR #831] Delay instantiation of cachedValues to save memory #766

Open
opened 2025-12-30 01:26:36 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/831
Author: @holzensp
Created: 11/27/2024
Status: 🔄 Open

Base: mainHead: nullCaches


📝 Commits (1)

  • c431327 Delay instantiation of cachedValues to save memory

📊 Changes

7 files changed (+46 additions, -18 deletions)

View changed files

📝 pkl-core/src/main/java/org/pkl/core/runtime/VmDynamic.java (+12 -4)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java (+5 -0)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java (+1 -1)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java (+3 -0)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java (+1 -1)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java (+18 -12)
📝 pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java (+6 -0)

📄 Description

I'm putting this up as a discussion piece, more than anything. Wins are minimal, at best.

The thinking was that every VmObject gets its cachedValues initialised by default, but only the ones that are forced get those values filled. However, cachedValues.entries is null by default. There appears to be a bigger possible win to address the fact that a lot of EconomicMaps have entries be an oversized array (Object[8] by default).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/831 **Author:** [@holzensp](https://github.com/holzensp) **Created:** 11/27/2024 **Status:** 🔄 Open **Base:** `main` ← **Head:** `nullCaches` --- ### 📝 Commits (1) - [`c431327`](https://github.com/apple/pkl/commit/c4313273517bb0e22abc859f6d05abc5135bf82d) Delay instantiation of `cachedValues` to save memory ### 📊 Changes **7 files changed** (+46 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmDynamic.java` (+12 -4) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java` (+5 -0) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java` (+1 -1) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java` (+3 -0) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java` (+1 -1) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java` (+18 -12) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java` (+6 -0) </details> ### 📄 Description I'm putting this up as a discussion piece, more than anything. Wins are minimal, at best. The thinking was that every `VmObject` gets its `cachedValues` initialised by default, but only the ones that are forced get those values filled. However, `cachedValues.entries` is `null` by default. There appears to be a bigger possible win to address the fact that a lot of `EconomicMap`s have `entries` be an oversized array (`Object[8]` by default). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:26:36 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#766