pjfanning opened a new pull request, #115: URL: https://github.com/apache/poi-xmlbeans/pull/115
Refs https://github.com/apache/poi/issues/992, where a 600MB workbook was reported to hold 2.35 million `AttrXobj` (216MB) and 1.17 million `ElementXobj` (108MB). `NamedNodeXobj` carries one boolean, `_canHavePrefixUri`, recording whether a node came from the DOM Level 1 factory methods (`createElement`/`createAttribute`), which must report `null` for `localName`, `namespaceURI` and `prefix`. `Xobj` already ends exactly on an 8-byte boundary at 88 bytes, so that single byte costs `AttrXobj` a whole slot — 89 bytes of fields padded out to a 96-byte object. `Xobj._bits` already packs `kind` (`0xF`), `domType` (`0xF0`) and three flags, the highest being `INHIBIT_DISCONNECT = 0x400`. Moving the boolean there as `CAN_HAVE_PREFIX_URI = 0x800` removes the field entirely. Measured with `Unsafe.objectFieldOffset` on the compiled classes, JDK 17 and JDK 21: | | trunk | this change | |---|---|---| | `Xobj` | 88 | 88 | | `AttrXobj` | 96 (7 bytes padding) | **88** | | `ElementXobj` | 96 | 96 | The saving also holds with `-XX:-UseCompressedOops` (152 → 144). For the reported workload that is roughly 19MB, about 3%. `ElementXobj` stays at 96 because it adds a 4-byte `_attributes` reference on top of 88; nothing in this change can help there. ### Relation to the patch proposed on the issue The issue proposes narrowing `_bits` from `int` to `short`, which produces exactly the same layout — I measured both, and combining them gains nothing further. This approach reaches the same result without changing the type, so there is no compound-assignment narrowing or sign-extension behaviour to reason about and no need for the range assertions that patch adds; `_bits` keeps all 32 bits available for future flags. Either is correct; this one is the smaller change to reason about. ### Behaviour Identical. The bit is set in the `NamedNodeXobj` constructor, cleared at the two DOM Level 1 factory sites, and set again on rename in `Xobj.setName` — the same three writes as before, and `NamedNodeXobj` remains the only reader. No other `Xobj` sets `0x800`. Added `NodePrefixUriFlagTest`, covering all three write paths. It passes on trunk as well — it is a characterisation test for the invariant this refactor must preserve, not a bug fix. Full suite: 3182 tests pass (170 skipped), including the W3C DOM conformance suite. `forbiddenApisMain` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
