Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(GGs): introduce GitFileSystemService as middleman interface #867

Merged
merged 16 commits into from
Aug 2, 2023

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Jul 27, 2023

Problem

Closes IS-320.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Features:

  • This PR introduces a new GitFileSystemService that can interface with the filesystem to perform Git-related operations.
    • As an MVP, only reading of files are supported
    • Some other functionality are also introduced, such as cloning, pulling, listing files in a directory and getting the Git blob hash

This PR is the first of a 2-part PR. The eventual architecture should look something like this:

IS-320

Tests

  1. Unit tests

Deploy Notes

New environment variables:

  • EFS_VOL_PATH : The path to the EFS volume used for storing the Git repositories

New dependencies:

  • simple-git : Wrapper for running Git-related operations on the underlying file system

New dev dependencies:

  • mock-fs : Provides a mock filesystem when performing unit tests

@dcshzj dcshzj changed the title feat(GGs feat(GGs): introduce GitFileSystemService as middleman interface Jul 27, 2023
@dcshzj dcshzj requested a review from a team July 27, 2023 06:01
Copy link
Contributor

@kishore03109 kishore03109 left a comment

Choose a reason for hiding this comment

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

Clarifications:
is this already funcitonal in local dev? is there a quick sanity check that I can do here to assert this?

[Style, Error Handling]: Lets not return an unknown, it would resolve to the top level, and it might not yield the usefulness of the types!

src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
}

// Pull the latest changes from upstream Git hosting provider
// TODO: Pulling is a very expensive operation, should find a way to optimise
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting note, out of curiosity why is this the case ah? I thought after the first git clone, the git pull should be ok no?
How expensive is this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Expensive in terms of latency? Latency of network call or disk write? Curious - did you manage to benchmark this on ur local?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't manage to dive into the exact cause of the latency issues, but just a quick benchmarking on my local machine, the Git pull operation adds almost 2 seconds in latency for each request (281 ms without, 2.91 seconds with pulling)

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, let's focus on latency once MVP is out as our baseline metric is the reduction of API calls

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought git checkout might help and I ran a simple benchmark, weirdly checkout is slower than pull?

❯ node benchmark.js
Time taken for git checkout: 3386.3763749599457 ms
Time taken for git pull: 3241.95516705513 ms
❯ node benchmark.js
Time taken for git checkout: 3356.351875066757 ms
Time taken for git pull: 3228.0880839824677 ms
❯ node benchmark.js
Time taken for git checkout: 3306.690124988556 ms
Time taken for git pull: 3079.9089580774307 ms
❯ node benchmark.js
Time taken for git pull: 2990.787334084511 ms
Time taken for git checkout: 3404.82679104805 ms

src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
)
}

return okAsync(null)
Copy link
Contributor

Choose a reason for hiding this comment

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

why return okAsync(null) over the path to the repo? (okAsync(path_to_repo))

)
}

return okAsync(null)
Copy link
Contributor

Choose a reason for hiding this comment

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

also, why not do a git fetch here? the repo is correct already but not guaranteed to be updated

src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/config/config.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
)
}

return okAsync(null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the git fetch help? In any read operation we are already performing a git pull first

}

// Pull the latest changes from upstream Git hosting provider
// TODO: Pulling is a very expensive operation, should find a way to optimise
Copy link
Contributor

Choose a reason for hiding this comment

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

Expensive in terms of latency? Latency of network call or disk write? Curious - did you manage to benchmark this on ur local?

src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
@dcshzj dcshzj requested a review from a team July 31, 2023 14:03
Copy link
Contributor

@kishore03109 kishore03109 left a comment

Choose a reason for hiding this comment

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

Good job on your first PR after coming back 👏 👏

Appreciate your detailed explanation, lgtm with nits

src/services/db/GitFileSystemService.ts Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
Copy link
Contributor

@harishv7 harishv7 left a comment

Choose a reason for hiding this comment

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

lgtm, some conflicts pending

@dcshzj dcshzj merged commit 89f4210 into develop Aug 2, 2023
@mergify mergify bot deleted the IS-320-create-new-interface-for-local-git-service-3 branch August 2, 2023 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants