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: Replace ULID raw record ID with UUID v7 #300

Merged
merged 4 commits into from
Jul 18, 2024

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Jul 18, 2024

Summary

  • Improved unique ID generation by switching from ULID to a custom UUID method, ensuring more robust and unique identifier creation.
    Chores

  • Updated dependencies in pyproject.toml, including the addition of the uuid7 and types-pyyaml packages, while removing ulid.

In the previous flamegraph, the ULID creation was taking approx. 4us, plus up to 5us to convert to str type. The UUID v7 implementation generates a UUID in one step in approx 2us. This cuts off approximately 7us out of ~26us processing time per record, or up to 30% of the per-record processing time.

Now (2us of 19us total):

image

Previous (4+5us, combined 9us of 27us total):

image

Notes:

  • ULIDs are still used for batch IDs, file name suffixes, and table name suffixes. This change only affects unique record IDs.
  • In working this PR, I found that there was an unused dependency on ulid library, where we are/were actually using python-ulid.
  • A nice added benefit is that the row IDs are now compatible with the UUID column type.

New benchmark (41K records / sec using the e2e source):

poetry run python ./examples/run_perf_test_reads.py -e=6 --source=e2e

image

Copy link

coderabbitai bot commented Jul 18, 2024

Walkthrough

Walkthrough

This update replaces the usage of ULID with UUID version 7 for generating unique IDs in the from_record_message function. It updates the dependencies in pyproject.toml to include the uuid7 package and removes the ulid package. Additionally, the Python version constraint for the sqlalchemy-bigquery package is adjusted, and the types-pyyaml package is added.

Changes

File Change Summary
airbyte/records.py Replaced ulid with uuid_extensions.uuid7str for generating unique IDs, updated import statements.
pyproject.toml Updated package versions including adding uuid7, removing ulid, adjusting constraints, and adding types-pyyaml.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1acd6df and 8754c70.

Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
Files selected for processing (2)
  • airbyte/records.py (2 hunks)
  • pyproject.toml (1 hunks)
Additional comments not posted (6)
airbyte/records.py (2)

75-75: Verify the new import.

Ensure that the uuid_extensions package is correctly installed and uuid7str is the correct function for generating UUID v7 strings.


145-145: Ensure correct integration of UUID v7.

The unique ID generation has been switched to uuid7str(). Verify that this change is correctly integrated and that the new IDs meet the required specifications.

pyproject.toml (4)

48-48: Verify the addition of the types-pyyaml package.

Ensure that the types-pyyaml package is correctly added and compatible with the project.

Verification successful

The types-pyyaml package has been correctly added to the pyproject.toml file.

  • The package is listed with the version ^6.0.12.12.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct addition of the `types-pyyaml` package.

# Test: Check if `types-pyyaml` package is installed.
pip show types-pyyaml

Length of output: 94


Script:

#!/bin/bash
# Description: Verify the correct addition of the `types-pyyaml` package in the pyproject.toml file.

# Search for the `types-pyyaml` entry in the pyproject.toml file.
grep 'types-pyyaml' pyproject.toml

Length of output: 62


48-48: Verify the adjustment of the sqlalchemy-bigquery package version constraint.

Ensure that the new version constraint for the sqlalchemy-bigquery package is correctly applied and compatible with the project.

Verification successful

The sqlalchemy-bigquery package version constraint has been correctly adjusted.

The sqlalchemy-bigquery package is specified with the version "1.9.0" and a Python constraint "<3.13" in the pyproject.toml file, which aligns with the intended adjustment.

  • pyproject.toml:
    sqlalchemy-bigquery = { version = "1.9.0", python = "<3.13" }
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the adjustment of the `sqlalchemy-bigquery` package version constraint.

# Test: Check if the `sqlalchemy-bigquery` package is installed with the correct version constraint.
pip show sqlalchemy-bigquery

Length of output: 101


Script:

#!/bin/bash
# Description: Verify the adjustment of the `sqlalchemy-bigquery` package version constraint by inspecting the pyproject.toml file.

# Search for the sqlalchemy-bigquery package entry in the pyproject.toml file and extract its version constraint.
rg 'sqlalchemy-bigquery' -A 1 pyproject.toml

Length of output: 218


48-48: Verify the addition of the uuid7 package.

Ensure that the uuid7 package is correctly added and compatible with the project.

Verification successful

The uuid7 package has been correctly added and is being utilized in the project.

  • pyproject.toml: uuid7 = "^0.1.0"
  • poetry.lock: Contains references to uuid7 package files.
  • airbyte/records.py: Contains code that uses uuid7.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct addition of the `uuid7` package.

# Test: Check if `uuid7` package is installed.
pip show uuid7

Length of output: 87


Script:

#!/bin/bash
# Description: Verify the correct addition of the `uuid7` package.

# Check if `uuid7` is listed in the `pyproject.toml` file.
rg 'uuid7' pyproject.toml

# Check for any references to `uuid7` in the codebase.
rg 'uuid7' .

Length of output: 522


48-48: Verify the removal of the ulid package.

Ensure that the ulid package is fully removed and no longer used in the project.

@aaronsteers aaronsteers changed the title Change: Replace ULID raw record ID with UUID v7 Feat: Replace ULID raw record ID with UUID v7 Jul 18, 2024
@aaronsteers aaronsteers merged commit 0616d8a into main Jul 18, 2024
15 checks passed
@aaronsteers aaronsteers deleted the feat/replace-ulid-raw-id-with-uuidv7 branch July 18, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant