|
1 | 1 | /* |
2 | | - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -722,8 +722,15 @@ double G1Policy::logged_cards_processing_time() const { |
722 | 722 | size_t logged_dirty_cards = phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards); |
723 | 723 | size_t scan_heap_roots_cards = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanHR, G1GCPhaseTimes::ScanHRScannedCards) + |
724 | 724 | phase_times()->sum_thread_work_items(G1GCPhaseTimes::OptScanHR, G1GCPhaseTimes::ScanHRScannedCards); |
725 | | - // This may happen if there are duplicate cards in different log buffers. |
726 | | - if (logged_dirty_cards > scan_heap_roots_cards) { |
| 725 | + // Approximate the time spent processing cards from log buffers by scaling |
| 726 | + // the total processing time by the ratio of logged cards to total cards |
| 727 | + // processed. There might be duplicate cards in different log buffers, |
| 728 | + // leading to an overestimate. That effect should be relatively small |
| 729 | + // unless there are few cards to process, because cards in buffers are |
| 730 | + // dirtied to limit duplication. Also need to avoid scaling when both |
| 731 | + // counts are zero, which happens especially during early GCs. So ascribe |
| 732 | + // all of the time to the logged cards unless there are more total cards. |
| 733 | + if (logged_dirty_cards >= scan_heap_roots_cards) { |
727 | 734 | return all_cards_processing_time + average_time_ms(G1GCPhaseTimes::MergeLB); |
728 | 735 | } |
729 | 736 | return (all_cards_processing_time * logged_dirty_cards / scan_heap_roots_cards) + average_time_ms(G1GCPhaseTimes::MergeLB); |
|
0 commit comments