Skip to content

Conversation

@ashmeenkaur
Copy link
Collaborator

@ashmeenkaur ashmeenkaur commented Jan 5, 2026

Description

This PR refactors the directory reading logic by introducing a new readObjectsUnlocked function to perform GCS I/O without holding the directory lock. This will allow for for more concurrent operations by minimizing lock contention during potentially long-running List calls which will become more frequent as we add dir-metadata-prefetch feature.

It also migrates the test suite from ogletest to the more standard testify/suite, which improves maintainability.

Link to the issue in case of a bug fix.

b/473411326

Testing details

  1. Manual - NA
  2. Unit tests - Added
  3. Integration tests - via KOKORO

Any backward incompatible change? If so, please explain.

NA

@ashmeenkaur ashmeenkaur added the execute-integration-tests Run only integration tests label Jan 5, 2026
@ashmeenkaur ashmeenkaur force-pushed the refactor-read-object branch 4 times, most recently from 01e0ce1 to ed6354f Compare January 6, 2026 00:07
@ashmeenkaur
Copy link
Collaborator Author

/gemini summary

@ashmeenkaur
Copy link
Collaborator Author

/gemini review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request introduces a significant refactoring to the directory inode's object reading mechanism, primarily by separating the GCS I/O from the cache update logic. A new readObjectsUnlocked function allows for more concurrent operations by minimizing lock contention during potentially long-running GCS calls. The changes also include a comprehensive update of the associated test file to use the testify assertion library, enhancing test readability and maintainability.

Highlights

  • New Functionality: Introduced a new readObjectsUnlocked function in dir.go designed to perform GCS I/O operations without holding a lock on the directory inode, improving concurrency. The lock is only acquired briefly to update the cache.
  • Refactoring: The existing readObjects function was refactored and renamed to listObjectsAndBuildCores. This new helper function now encapsulates the common logic for listing objects and building core metadata, separating it from the cache insertion logic.
  • Helper Function: A new private helper function insertToCache was added to centralize the logic for inserting object metadata into the directory's type cache.
  • Testing Framework Update: The test suite in dir_test.go was migrated from oglematchers and ogletest to github.com/stretchr/testify (specifically assert, require, and suite), leading to more idiomatic Go testing practices and clearer assertions.
  • New Test Cases: Added dedicated test cases (Test_ReadObjectsUnlocked and Test_readObjectsUnlocked_Empty) to thoroughly validate the behavior and locking mechanism of the newly introduced readObjectsUnlocked function.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • internal/fs/inode/dir.go
    • Renamed readObjects to listObjectsAndBuildCores to better reflect its purpose as a GCS listing and core building helper.
    • Created a new insertToCache function to encapsulate cache insertion logic.
    • Implemented readObjectsUnlocked which calls listObjectsAndBuildCores and then acquires a lock to call insertToCache.
    • Modified the original readObjects to utilize the new listObjectsAndBuildCores and insertToCache functions.
  • internal/fs/inode/dir_test.go
    • Replaced oglematchers and ogletest imports with github.com/stretchr/testify/assert, require, and suite.
    • Updated test suite setup methods (SetUp, TearDown) to SetupTest and TearDownTestSuite for testify compatibility.
    • Converted all existing assertions from AssertEq, ExpectEq, AssertNe, ExpectNe, AssertTrue, ExpectTrue, AssertFalse, ExpectFalse, ExpectThat to their testify equivalents (require.NoError, assert.Equal, require.NotNil, assert.EqualValues, require.True, assert.True, require.False, assert.False, assert.ErrorContains, assert.ElementsMatch).
    • Renamed all test functions to follow the Test<FunctionName> convention required by testify.
    • Added new test cases Test_ReadObjectsUnlocked and Test_readObjectsUnlocked_Empty to verify the functionality of the new readObjectsUnlocked method.
Activity
  • The author ashmeenkaur requested a summary of the pull request.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the directory object reading logic by introducing a new readObjectsUnlocked function to perform GCS I/O without holding the directory lock, which is a good performance improvement. It also migrates the test suite from ogletest to the more standard testify/suite, which improves maintainability. However, the refactoring in dir.go has introduced a critical race condition and a redundant operation due to incomplete removal of old logic. The tests have also been updated accordingly, but there's a minor typo in one of the test names.

@ashmeenkaur ashmeenkaur marked this pull request as ready for review January 6, 2026 00:21
@ashmeenkaur ashmeenkaur requested a review from a team as a code owner January 6, 2026 00:21
@github-actions github-actions bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Jan 6, 2026
@ashmeenkaur ashmeenkaur changed the title feat(dir-metadata-prefetch): create readObjectsUnlocked function and refactoring feat(dir-metadata-prefetch): create readObjectsUnlocked function + refactoring of existing code Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.13%. Comparing base (8985dad) to head (039fc04).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
internal/fs/inode/dir.go 78.94% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4240      +/-   ##
==========================================
+ Coverage   83.09%   83.13%   +0.03%     
==========================================
  Files         154      154              
  Lines       18980    18994      +14     
==========================================
+ Hits        15772    15791      +19     
+ Misses       2631     2627       -4     
+ Partials      577      576       -1     
Flag Coverage Δ
unittests 83.13% <78.94%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Hi @vadlakondaswetha, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@ashmeenkaur ashmeenkaur requested a review from charith87 January 7, 2026 06:02
@ashmeenkaur ashmeenkaur force-pushed the refactor-read-object branch from 96414d1 to 039fc04 Compare January 7, 2026 09:16
@ashmeenkaur ashmeenkaur enabled auto-merge (squash) January 7, 2026 10:24
@ashmeenkaur ashmeenkaur merged commit ccd1584 into master Jan 7, 2026
15 checks passed
@ashmeenkaur ashmeenkaur deleted the refactor-read-object branch January 7, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants