tomerr90 commented on PR #19334:
URL: https://github.com/apache/iceberg/pull/19334#issuecomment-7447876307

   Memory and latency comparison of the current `StructLikeMap<PathOffset>` and 
this PR's `InsertedRowMap` (Apple M5 Pro, Temurin 21.0.11).
   
   **Retained heap per entry**, 10M keys, post-GC heap delta 
([harness](https://gist.github.com/tomerr90/0c47ffae1a55d046dd8e098d88fa620c)); 
JOL `GraphLayout` walks agree within ~2 B:
   
   | Equality key | Before | After | Reduction |
   |---|---|---|---|
   | UUID string | 232 B | 88 B | 2.6x |
   | string (20 chars) + timestamp | 240 B | 80 B | 3.0x |
   | random 64-bit long | 176 B | 64 B | 2.8x |
   
   Before, the 240 B of a string + timestamp entry are 9 objects (JOL): 
`HashMap$Node` 32, `StructLikeWrapper` 32, boxed `Integer` hash 16, 
`StructCopy` 16, `Object[]` 24, `String` 24 + its `byte[]` 40, boxed `Long` 24, 
`PathOffset` 24, plus ~8 for the table slot. After, it is one ~48 B `byte[]` 
plus ~33 B of primitive table arrays.
   
   **Upsert latency**, JMH `InsertedRowMapBenchmark` (included in the PR), 4M 
upserts of `remove` then `put`, rows returning a new `String` per `get()` like 
Flink's `RowDataWrapper`, 3 forks x 10 iterations:
   
   | Key, distinct keys | Before | After |
   |---|---|---|
   | string + timestamp, 4M (every key new) | 1177 ± 26 ms (294 ns/upsert) | 
1114 ± 12 ms (278 ns/upsert) |
   | string + timestamp, 1M (keys repeat) | 1904 ± 27 ms (476 ns/upsert) | 974 
± 20 ms (244 ns/upsert) |
   | long, 4M (every key new) | 702 ± 23 ms (175 ns/upsert) | 673 ± 6 ms (168 
ns/upsert) |
   | long, 1M (keys repeat) | 1021 ± 87 ms (255 ns/upsert) | 765 ± 15 ms (191 
ns/upsert) |
   
   <details>
   <summary>Raw JMH output</summary>
   
   ```
   Benchmark                               (distinctKeys)        (keyShape)  
Mode  Cnt     Score    Error  Units
   InsertedRowMapBenchmark.insertedRowMap         4000000  string_timestamp    
ss   30  1113.533 ± 11.807  ms/op
   InsertedRowMapBenchmark.insertedRowMap         4000000              long    
ss   30   673.305 ±  6.478  ms/op
   InsertedRowMapBenchmark.insertedRowMap         1000000  string_timestamp    
ss   30   974.389 ± 19.987  ms/op
   InsertedRowMapBenchmark.insertedRowMap         1000000              long    
ss   30   764.598 ± 15.197  ms/op
   InsertedRowMapBenchmark.structLikeMap          4000000  string_timestamp    
ss   30  1176.518 ± 25.540  ms/op
   InsertedRowMapBenchmark.structLikeMap          4000000              long    
ss   30   701.935 ± 23.170  ms/op
   InsertedRowMapBenchmark.structLikeMap          1000000  string_timestamp    
ss   30  1903.863 ± 26.967  ms/op
   InsertedRowMapBenchmark.structLikeMap          1000000              long    
ss   30  1021.317 ± 87.313  ms/op
   ```
   </details>
   
   <details>
   <summary>Raw memory output</summary>
   
   ```
   before uuid-string          n=10,000,000  retained=2,216 MiB  232.5 B/entry
   before string20+timestamp   n=10,000,000  retained=2,294 MiB  240.6 B/entry
   before long                 n=10,000,000  retained=1,682 MiB  176.4 B/entry
   after  uuid-string          n=10,000,000  retained=839 MiB  88.0 B/entry
   after  string20+timestamp   n=10,000,000  retained=762 MiB  79.9 B/entry
   after  long                 n=10,000,000  retained=608 MiB  63.8 B/entry
   ```
   </details>
   


-- 
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]

Reply via email to