dedyoc opened a new pull request, #4302:
URL: https://github.com/apache/iceberg-python/pull/4302

   Closes #4294
   
   # Rationale for this change
   
   `Transaction.table_metadata` replays the staged updates on every read:
   
   
https://github.com/apache/iceberg-python/blob/718c7908b36117974257e3d214959bffcada14a1/pyiceberg/table/__init__.py#L276-L278
   
   and `update_table_metadata` always ends in a deep copy:
   
   
https://github.com/apache/iceberg-python/blob/718c7908b36117974257e3d214959bffcada14a1/pyiceberg/table/update/__init__.py#L763
   
   An append reads the property about 20 times before staging anything, so 
every read deep copies the full snapshot history. This returns the table's 
metadata directly when nothing is staged, as @geruh suggested on #3302. 
`Table.metadata` already shares that object uncopied.
   
   The reproduction script from #4294, on `main` with and without this change 
(one timed append per depth):
   
   | Snapshots | Before | After | `update_table_metadata` calls |
   | --- | --- | --- | --- |
   | 100 | 101.3 ms | 18.6 ms | 22 → 1 |
   | 200 | 105.6 ms | 27.9 ms | 22 → 1 |
   | 400 | 245.6 ms | 44.6 ms | 22 → 1 |
   | 800 | 541.5 ms | 81.9 ms | 22 → 1 |
   
   ## Are these changes tested?
   
   Yes. Two tests in `tests/table/test_init.py` check that with nothing staged 
the property returns the table's own metadata object and that staged updates 
are still applied without changing the table's metadata.
   
   `test_snapshot_producer_bounded_metadata_access` counts 
`update_table_metadata` calls as a stand-in for reads of the property, so it 
now stages an update first, otherwise every read would skip the call. It still 
fails if a read is added back to the snapshot producer.
   
   ## Are there any user-facing changes?
   
   No.


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