Changes between Initial Version and Version 1 of Ticket #4142, comment 27


Ignore:
Timestamp:
2023-11-13T20:43:28+01:00 (15 months ago)
Author:
taylor.smock

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #4142, comment 27

    initial v1  
    22
    33With that said, now I'm wondering if the `short flags` still saves memory. I assume it did once, but the JVM has advanced significantly since at least 2011 (when the `short flags` got moved from `OsmPrimitive` to `AbstractPrimitive`). Time for some heap dumps...
     4
     5EDIT: Using short bits is still more space efficient. Tested with sixteen `boolean` fields in a class (both `record` and `traditional`), a class with a `boolean[]` field, and a class with a `short` field. 20k instances of the `boolean` field class was 640kb. 20k instances of the `short` field instance was 320kb. The `boolean[]` field array class was the worst at 960kb. All values were randomly generated to avoid any efficiency shortcuts from the JVM.
     6
     7Just for the heck of it, I also took a look at [https://openjdk.org/jeps/401 JEP 401] value objects. I don't know what is going on, but (as of the [https://jdk.java.net/valhalla/ Valhalla JDK 20 EA] build), it was not as efficient as the `short` field (it was as efficient as the more standard classes). This should probably be double-checked using real data in production once we move to a JVM with value classes.