You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2025/07/04 09:34:02 UTC

[PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

ibessonov opened a new pull request, #6188:
URL: https://github.com/apache/ignite-3/pull/6188

   https://issues.apache.org/jira/browse/IGNITE-25838
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #6188:
URL: https://github.com/apache/ignite-3/pull/6188#discussion_r2184915994


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/replacement/ClockPageReplacementFlags.java:
##########
@@ -113,7 +111,20 @@ boolean getFlag(int pageIdx) {
      * @param pageIdx Page index.
      */
     public void clearFlag(int pageIdx) {
-        compareAndSwapFlag(pageIdx, flags -> flags & ~(1L << pageIdx));
+        long ptr = flagsPtr + ((pageIdx >> 3) & (~7L));

Review Comment:
   How about extracting the method to compute ptr? Also, there are magic constants. Is it possible to extract named constants?



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #6188:
URL: https://github.com/apache/ignite-3/pull/6188#discussion_r2184976139


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/replacement/ClockPageReplacementFlags.java:
##########
@@ -113,7 +111,20 @@ boolean getFlag(int pageIdx) {
      * @param pageIdx Page index.
      */
     public void clearFlag(int pageIdx) {
-        compareAndSwapFlag(pageIdx, flags -> flags & ~(1L << pageIdx));
+        long ptr = flagsPtr + ((pageIdx >> 3) & (~7L));

Review Comment:
   I can extract computations, but I'm afraid that constants would make the code less readable. You know off the bat what `~7L` means, while parsing a name and identifying what it means takes more time. What this class really needs is some documentation



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #6188:
URL: https://github.com/apache/ignite-3/pull/6188#discussion_r2184976139


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/replacement/ClockPageReplacementFlags.java:
##########
@@ -113,7 +111,20 @@ boolean getFlag(int pageIdx) {
      * @param pageIdx Page index.
      */
     public void clearFlag(int pageIdx) {
-        compareAndSwapFlag(pageIdx, flags -> flags & ~(1L << pageIdx));
+        long ptr = flagsPtr + ((pageIdx >> 3) & (~7L));

Review Comment:
   I can extract computations, but I'm afraid that constants would the code less readable. You know off the bat what `~7L` means, while parsing a name and identifying what it means takes more time. What this class really needs is some documentation



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #6188:
URL: https://github.com/apache/ignite-3/pull/6188#discussion_r2185009702


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/replacement/ClockPageReplacementFlags.java:
##########
@@ -113,7 +111,20 @@ boolean getFlag(int pageIdx) {
      * @param pageIdx Page index.
      */
     public void clearFlag(int pageIdx) {
-        compareAndSwapFlag(pageIdx, flags -> flags & ~(1L << pageIdx));
+        long ptr = flagsPtr + ((pageIdx >> 3) & (~7L));

Review Comment:
   > You know off the bat what ~7L means
   
   I don't :) I have to figure out that it's 0b111, flip it (all within my head) and then guess the intentions behind this. I thought it was possible to communicate the intention directly via constant name. But if it's not the case, let it be in the current form.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25838 Remove lambdas from ClockPageReplacementFlags [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #6188:
URL: https://github.com/apache/ignite-3/pull/6188


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org