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

Update VersionVector Operations for In-Place Comparison #1170

Merged
merged 3 commits into from
Feb 28, 2025

Conversation

chacha912
Copy link
Contributor

@chacha912 chacha912 commented Feb 25, 2025

What this PR does / why we need it:

The Min() and Max() functions have been updated to operate in-place, which allows us to simplify our version vector comparison logic. Refactored the code to use the in-place Min() method instead of database.FindMinVersionVector.

  • Removed database.FindMinVersionVector function as it's no longer necessary
  • Updated code to use the in-place Min() method directly

Which issue(s) this PR fixes:

Related #1164

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Addressed and resolved all CodeRabbit review comments
  • Didn't break anything

Summary by CodeRabbit

  • Refactor

    • Streamlined the underlying logic for merging version data during synchronization. These improvements enhance consistency and reliability in handling collaborative updates and conflict resolution.
    • Removed redundant internal components to simplify processing and improve overall performance, leading to a more stable and efficient experience for end users.
    • Updated methods to modify version vectors in-place, improving efficiency in version management.
    • Simplified the computation of minimum version vectors, enhancing clarity and reducing complexity.
  • Bug Fixes

    • Adjusted test logic to ensure accurate assertions regarding version vector calculations.

@chacha912 chacha912 requested a review from raararaara February 25, 2025 09:35
Copy link

coderabbitai bot commented Feb 25, 2025

Walkthrough

This pull request updates the logic used to compute the minimum and maximum between version vectors. In the VersionVector type, the comparison conditions in the Min and Max methods are reversed, changing which value is retained. Additionally, the redundant helper function for finding the minimum version vector and its associated tests have been removed. The consolidation of the minimum vector computation into the UpdateAndFindMinSyncedVersionVector methods in both memory and mongo implementations simplifies the control flow and removes extra function calls and conditional logic.

Changes

File(s) Change Summary
pkg/document/time/version_vector.go Updated the logic in the Min and Max methods: conditions reversed so that Min now retains the greater value and Max retains the lesser value when keys are present in both vectors.
server/backend/database/database_test.go
server/backend/database/version_vector.go
Removed the TestFindMinVersionVector test and the FindMinVersionVector helper function, eliminating redundant verification of minimum vector computation.
server/backend/database/memory/database.go
server/backend/database/mongo/client.go
Refactored the UpdateAndFindMinSyncedVersionVector method to initialize with a deep copy of the current version vector and update it in a single loop using the revised Min method, streamlining the computation.
pkg/document/change/id.go Simplified the handling of versionVector in SyncClocks and SetClocks methods by removing the maximum calculation and directly assigning the current versionVector to newID.
pkg/document/time/version_vector_test.go Modified the TestVersionVector function to directly assert the state of tc.v1 after the Min operation, removing the intermediate result variable.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Database Client
    participant Updater as UpdateAndFindMinSyncedVersionVector
    participant VV as Current Version Vector
    participant Other as Other Version Vectors

    Client->>Updater: Call UpdateAndFindMinSyncedVersionVector
    Updater->>VV: Create deep copy of current version vector
    loop For each version vector info (excluding current client)
        VV->>VV: Compute updated value using Min method with other version vector
    end
    Updater->>Client: Return computed min version vector
Loading

Possibly related PRs

Suggested reviewers

  • hackerwins

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc2a880 and dc7ee81.

📒 Files selected for processing (5)
  • pkg/document/change/id.go (2 hunks)
  • pkg/document/time/version_vector.go (2 hunks)
  • pkg/document/time/version_vector_test.go (1 hunks)
  • server/backend/database/memory/database.go (1 hunks)
  • server/backend/database/mongo/client.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/backend/database/memory/database.go
  • server/backend/database/mongo/client.go
🧰 Additional context used
🧠 Learnings (1)
pkg/document/time/version_vector.go (2)
Learnt from: chacha912
PR: yorkie-team/yorkie#1164
File: pkg/document/time/version_vector.go:158-183
Timestamp: 2025-02-21T04:54:17.948Z
Learning: In the Yorkie project, the `VersionVector.Min` and `VersionVector.Max` methods should maintain consistent behavior and documentation. Both methods should modify the receiver in-place for memory efficiency, take pointer parameters, and document their side effects clearly.
Learnt from: hackerwins
PR: yorkie-team/yorkie#1164
File: pkg/document/time/version_vector.go:158-183
Timestamp: 2025-02-20T11:31:21.714Z
Learning: In the Yorkie project, the `VersionVector.Max` method modifies the receiver in-place and returns it, which is an intentional design decision for memory efficiency. The method takes a pointer parameter but only reads from it, maintaining input integrity.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: complex-test
  • GitHub Check: build
  • GitHub Check: bench
🔇 Additional comments (7)
pkg/document/time/version_vector.go (4)

133-136: Documentation update looks good

The updated documentation clearly indicates that the Min method now modifies the receiver in-place, which aligns with the signature change removing the return value.


137-152: Logic reversal in Min method is correct

The condition has been reversed from value < otherValue to value > otherValue when calculating the minimum value between vectors. This change correctly ensures that the smaller value is kept when both keys exist in both vectors, aligning with the mathematical definition of a minimum operation.


154-157: Documentation update for Max is appropriate

The documentation now clearly explains that the Max method modifies the receiver in-place, matching the behavior change made in the implementation.


158-171: Logic reversal in Max method is correct

The condition has been reversed from value > otherValue to value < otherValue when calculating the maximum value between vectors. This change correctly ensures that the larger value is kept when keys exist in both vectors, aligning with the mathematical definition of a maximum operation.

pkg/document/change/id.go (2)

115-117: In-place modification properly implemented

The code now correctly uses the in-place Max operation on id.versionVector before passing it to NewID. This aligns with the updated behavior of the Max method in the VersionVector type.


138-140: Consistent usage of in-place Max operation

The in-place Max operation is consistently used here as well, ensuring the version vector is properly updated before creating the new ID.

pkg/document/time/version_vector_test.go (1)

104-105: Test updated to match in-place modification behavior

The test has been properly updated to call tc.v1.Min(&tests[i].v2) without assigning to a result variable, and then asserting that tc.v1 itself equals the expected value. This correctly tests the new in-place modification behavior of the Min method.

✨ Finishing Touches
  • 📝 Generate Docstrings

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

🧹 Nitpick comments (2)
server/backend/database/memory/database.go (1)

1369-1375: Address potential implicit memory aliasing when passing version vectors

Static analysis flags possible memory aliasing in the loop. Although it may not cause immediate errors in this context, consider creating a local copy of vvi.VersionVector before calling Min. This can prevent unexpected behavior in concurrency scenarios or future refactors.

A possible approach:

 for _, vvi := range versionVectorInfos {
   if vvi.ClientID == clientInfo.ID {
     continue
   }
-  minVersionVector.Min(&vvi.VersionVector)
+  localCopy := vvi.VersionVector.DeepCopy()
+  minVersionVector.Min(&localCopy)
 }
🧰 Tools
🪛 GitHub Check: build

[failure] 1375-1375:
G601: Implicit memory aliasing in for loop. (gosec)

server/backend/database/mongo/client.go (1)

1261-1267: Consider creating a local copy to avoid implicit memory aliasing

Passing &vvi.VersionVector directly in the loop can trigger implicit memory aliasing warnings. While likely safe here, making a local copy can help avoid subtle issues if the code changes or is accessed concurrently.

A possible approach:

 for _, vvi := range versionVectorInfos {
   if vvi.ClientID == clientInfo.ID {
     continue
   }
-  minVersionVector.Min(&vvi.VersionVector)
+  localCopy := vvi.VersionVector.DeepCopy()
+  minVersionVector.Min(&localCopy)
 }
🧰 Tools
🪛 GitHub Check: build

[failure] 1267-1267:
G601: Implicit memory aliasing in for loop. (gosec)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fd75be and dc2a880.

📒 Files selected for processing (5)
  • pkg/document/time/version_vector.go (2 hunks)
  • server/backend/database/database_test.go (0 hunks)
  • server/backend/database/memory/database.go (1 hunks)
  • server/backend/database/mongo/client.go (1 hunks)
  • server/backend/database/version_vector.go (0 hunks)
💤 Files with no reviewable changes (2)
  • server/backend/database/version_vector.go
  • server/backend/database/database_test.go
🧰 Additional context used
🧠 Learnings (1)
pkg/document/time/version_vector.go (2)
Learnt from: chacha912
PR: yorkie-team/yorkie#1164
File: pkg/document/time/version_vector.go:158-183
Timestamp: 2025-02-21T04:54:17.948Z
Learning: In the Yorkie project, the `VersionVector.Min` and `VersionVector.Max` methods should maintain consistent behavior and documentation. Both methods should modify the receiver in-place for memory efficiency, take pointer parameters, and document their side effects clearly.
Learnt from: hackerwins
PR: yorkie-team/yorkie#1164
File: pkg/document/time/version_vector.go:158-183
Timestamp: 2025-02-20T11:31:21.714Z
Learning: In the Yorkie project, the `VersionVector.Max` method modifies the receiver in-place and returns it, which is an intentional design decision for memory efficiency. The method takes a pointer parameter but only reads from it, maintaining input integrity.
🪛 GitHub Check: build
server/backend/database/memory/database.go

[failure] 1375-1375:
G601: Implicit memory aliasing in for loop. (gosec)

server/backend/database/mongo/client.go

[failure] 1267-1267:
G601: Implicit memory aliasing in for loop. (gosec)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: bench
  • GitHub Check: complex-test
🔇 Additional comments (2)
pkg/document/time/version_vector.go (2)

143-145: Logic correction for Min function looks good

Changing the condition to if value > otherValue ensures the receiver holds the smaller value, aligning with the intended “minimum” behavior.


170-172: Logic correction for Max function looks good

Changing the condition to if value < otherValue ensures the receiver holds the larger value, aligning with the intended “maximum” behavior.

Copy link

@hackerwins-yorkie hackerwins-yorkie left a comment

Choose a reason for hiding this comment

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

Go Benchmark Analysis 📊

This is a comparison result between the previous(e687d61) and the current commit(c7d2869).

Significant Changes (≥20% difference)

Benchmark suite Previous Current Change
BenchmarkVersionVector/clients_1000/ (B/op) 22.07 GB 6.43 GB 🟢 -70.85%
BenchmarkVersionVector/clients_1000/ (4_attach(ms)) 249.00 ms 74.00 ms 🟢 -70.28%
BenchmarkSplayTree/editing_trace_bench/ (ns/op) 0.00 ns 0.00 ns 🔴 +28.11%
BenchmarkVersionVector/clients_1000/ (ns/op) 60.97 s 44.68 s 🟢 -26.72%
BenchmarkVersionVector/clients_1000/ (3_pushpull(ms)) 95.00 ms 116.00 ms 🔴 +22.11%

Key Observations 🔍

  • The benchmark suite BenchmarkVersionVector/clients_1000/ showed a significant improvement in performance with a -70.85% decrease in memory consumption from 22.07 GB to 6.43 GB. This indicates a substantial optimization in resource usage for this specific benchmark.
  • In the BenchmarkTree suite, the operation 10000_vertices_to_protobuf/ showed a +1.05% increase in speed from 4.17 ms to 4.22 ms. While this increase is not significant, it indicates a slight performance degradation in this specific operation.
  • Overall, several benchmarks exhibited improvements in performance or resource consumption, such as array_test/ showing a -2.22% decrease and text_split_gc_1000/ displaying a -1.24% decrease. These improvements suggest ongoing optimization efforts across various benchmark suites.

Clock Analysis

Lamport (v0.5.2)

Metric 10 clients 100 clients 1000 clients
Total Operation Time 84.96 ms 793.94 ms 34.79 s
Memory Allocations 35.11 MB 219.92 MB 4.91 GB
Number of Allocations (allocs/op) 69,271 1,246,728 81,485,288
ChangePack Size 138.0 B 137.0 B 141.0 B
Snapshot Size 379.0 B 3.08 KB 30.08 KB
Push-Pull Time 2.0 ms 1.5 ms 4.0 ms
Attach Time 4.5 ms 11.0 ms 31.0 ms
ChangePack After Detach 138.0 B 140.0 B 141.0 B
Snapshot After Detach 136.0 B 137.0 B 139.0 B
Push-Pull After Detach 2.5 ms 5.0 ms 9.5 ms

VV (current)

Metric 10 clients 100 clients 1000 clients
Total Operation Time 157.67 ms 1.40 s 44.68 s
Memory Allocations 20.14 MB 216.79 MB 6.43 GB
Number of Allocations (allocs/op) 83,257 1,481,361 93,353,673
ChangePack Size 745.00 B 6.14 KB 60.16 KB
Snapshot Size 379.00 B 3.08 KB 30.08 KB
Push-Pull Time 7.00 ms 12.00 ms 116.00 ms
Attach Time 6.00 ms 9.00 ms 74.00 ms
ChangePack After Detach 805.00 B 6.21 KB 60.22 KB
Snapshot After Detach 136.00 B 137.00 B 139.00 B
Push-Pull After Detach 8.00 ms 9.00 ms 23.00 ms

Summary

  • Total Operation Time:
    • Lamport has faster operation times across all client volumes compared to Version Vector.
  • Memory Allocations:
    • Version Vector has lower memory allocations for 10 and 100 clients, but Lamport is more efficient for 1000 clients.
  • ChangePack Size:
    • Version Vector has larger ChangePack sizes compared to Lamport.
  • Attach Time:
    • Lamport has significantly lower attach times compared to Version Vector for 1000 clients.
  • Push-Pull After Detach:
    • Version Vector performs better in push-pull times after detach for 1000 clients.

Detailed Test Results

BenchmarkDocument
Benchmark suite Previous Current Change
constructor_test/ (ns/op) 1439.00 ns 1507.00 ns 🔴 +4.73%
constructor_test/ (B/op) 1.39 KB 1.43 KB 🔴 +3.47%
constructor_test/ (allocs/op) 24 allocs 25 allocs 🔴 +4.17%
status_test/ (ns/op) 1028.00 ns 1075.00 ns 🔴 +4.57%
status_test/ (B/op) 1.35 KB 1.40 KB 🔴 +3.55%
status_test/ (allocs/op) 22 allocs 23 allocs 🔴 +4.55%
equals_test/ (ns/op) 7864.00 ns 8051.00 ns 🔴 +2.38%
equals_test/ (B/op) 7.56 KB 7.71 KB 🔴 +1.90%
equals_test/ (allocs/op) 129 allocs 132 allocs 🔴 +2.33%
nested_update_test/ (ns/op) 17079.00 ns 17187.00 ns 🔴 +0.63%
nested_update_test/ (B/op) 12.31 KB 12.36 KB 🔴 +0.39%
nested_update_test/ (allocs/op) 258 allocs 259 allocs 🔴 +0.39%
delete_test/ (ns/op) 27313.00 ns 23136.00 ns 🟢 -15.29%
delete_test/ (B/op) 15.79 KB 15.84 KB 🔴 +0.30%
delete_test/ (allocs/op) 339 allocs 340 allocs 🔴 +0.29%
object_test/ (ns/op) 8546.00 ns 9815.00 ns 🔴 +14.85%
object_test/ (B/op) 7.03 KB 7.08 KB 🔴 +0.70%
object_test/ (allocs/op) 118 allocs 119 allocs 🔴 +0.85%
array_test/ (ns/op) 28984.00 ns 28340.00 ns 🟢 -2.22%
array_test/ (B/op) 12.14 KB 12.19 KB 🔴 +0.40%
array_test/ (allocs/op) 273 allocs 274 allocs 🔴 +0.37%
text_test/ (ns/op) 32155.00 ns 31879.00 ns 🟢 -0.86%
text_test/ (B/op) 15.19 KB 15.24 KB 🔴 +0.32%
text_test/ (allocs/op) 484 allocs 485 allocs 🔴 +0.21%
text_composition_test/ (ns/op) 31674.00 ns 31648.00 ns 🟢 -0.08%
text_composition_test/ (B/op) 18.70 KB 18.75 KB 🔴 +0.26%
text_composition_test/ (allocs/op) 501 allocs 502 allocs 🔴 +0.20%
rich_text_test/ (ns/op) 87424.00 ns 86013.00 ns 🟢 -1.61%
rich_text_test/ (B/op) 39.36 KB 39.40 KB 🔴 +0.11%
rich_text_test/ (allocs/op) 1,146 allocs 1,147 allocs 🔴 +0.09%
counter_test/ (ns/op) 18201.00 ns 18258.00 ns 🔴 +0.31%
counter_test/ (B/op) 11.81 KB 11.86 KB 🔴 +0.40%
counter_test/ (allocs/op) 253 allocs 254 allocs 🔴 +0.40%
text_edit_gc_100/ (ns/op) 1.39 ms 1.42 ms 🔴 +2.26%
text_edit_gc_100/ (B/op) 864.90 KB 865.02 KB 🔴 +0.01%
text_edit_gc_100/ (allocs/op) 17,281 allocs 17,283 allocs 🔴 +0.01%
text_edit_gc_1000/ (ns/op) 53.39 ms 53.15 ms 🟢 -0.45%
text_edit_gc_1000/ (B/op) 46.84 MB 46.84 MB ⚪ 0%
text_edit_gc_1000/ (allocs/op) 185,598 allocs 185,598 allocs ⚪ 0%
text_split_gc_100/ (ns/op) 2.12 ms 2.14 ms 🔴 +0.70%
text_split_gc_100/ (B/op) 1.58 MB 1.58 MB ⚪ 0%
text_split_gc_100/ (allocs/op) 15,950 allocs 15,953 allocs 🔴 +0.02%
text_split_gc_1000/ (ns/op) 128.25 ms 129.73 ms 🔴 +1.16%
text_split_gc_1000/ (B/op) 137.79 MB 137.79 MB ⚪ 0%
text_split_gc_1000/ (allocs/op) 185,000 allocs 184,990 allocs ⚪ 0%
text_delete_all_10000/ (ns/op) 18.43 ms 17.71 ms 🟢 -3.93%
text_delete_all_10000/ (B/op) 10.58 MB 10.58 MB 🔴 +0.02%
text_delete_all_10000/ (allocs/op) 56,134 allocs 56,138 allocs ⚪ 0%
text_delete_all_100000/ (ns/op) 312.31 ms 289.39 ms 🟢 -7.34%
text_delete_all_100000/ (B/op) 105.54 MB 105.53 MB 🟢 -0.01%
text_delete_all_100000/ (allocs/op) 566,133 allocs 566,084 allocs ⚪ 0%
text_100/ (ns/op) 234634.00 ns 232250.00 ns 🟢 -1.02%
text_100/ (B/op) 120.94 KB 120.95 KB 🔴 +0.01%
text_100/ (allocs/op) 5,181 allocs 5,182 allocs 🔴 +0.02%
text_1000/ (ns/op) 2.46 ms 2.47 ms 🔴 +0.07%
text_1000/ (B/op) 1.16 MB 1.16 MB ⚪ 0%
text_1000/ (allocs/op) 51,084 allocs 51,085 allocs ⚪ 0%
array_1000/ (ns/op) 1.24 ms 1.25 ms 🔴 +1.04%
array_1000/ (B/op) 1.09 MB 1.09 MB ⚪ 0%
array_1000/ (allocs/op) 11,879 allocs 11,880 allocs ⚪ 0%
array_10000/ (ns/op) 13.33 ms 13.58 ms 🔴 +1.83%
array_10000/ (B/op) 9.89 MB 9.89 MB ⚪ 0%
array_10000/ (allocs/op) 120,735 allocs 120,734 allocs ⚪ 0%
array_gc_100/ (ns/op) 131750.00 ns 133109.00 ns 🔴 +1.03%
array_gc_100/ (B/op) 99.89 KB 99.94 KB 🔴 +0.05%
array_gc_100/ (allocs/op) 1,266 allocs 1,267 allocs 🔴 +0.08%
array_gc_1000/ (ns/op) 1.42 ms 1.47 ms 🔴 +3.30%
array_gc_1000/ (B/op) 1.14 MB 1.14 MB ⚪ 0%
array_gc_1000/ (allocs/op) 12,926 allocs 12,927 allocs ⚪ 0%
counter_1000/ (ns/op) 202098.00 ns 207624.00 ns 🔴 +2.73%
counter_1000/ (B/op) 178.13 KB 178.18 KB 🔴 +0.03%
counter_1000/ (allocs/op) 5,771 allocs 5,772 allocs 🔴 +0.02%
counter_10000/ (ns/op) 2.17 ms 2.20 ms 🔴 +1.61%
counter_10000/ (B/op) 2.07 MB 2.07 MB ⚪ 0%
counter_10000/ (allocs/op) 59,778 allocs 59,779 allocs ⚪ 0%
object_1000/ (ns/op) 1.39 ms 1.46 ms 🔴 +5.38%
object_1000/ (B/op) 1.44 MB 1.44 MB ⚪ 0%
object_1000/ (allocs/op) 9,925 allocs 9,925 allocs ⚪ 0%
object_10000/ (ns/op) 14.82 ms 15.74 ms 🔴 +6.25%
object_10000/ (B/op) 12.35 MB 12.35 MB ⚪ 0%
object_10000/ (allocs/op) 101,232 allocs 101,228 allocs ⚪ 0%
tree_100/ (ns/op) 1.02 ms 1.10 ms 🔴 +7.87%
tree_100/ (B/op) 951.02 KB 951.08 KB ⚪ 0%
tree_100/ (allocs/op) 6,102 allocs 6,103 allocs 🔴 +0.02%
tree_1000/ (ns/op) 74.23 ms 81.60 ms 🔴 +9.93%
tree_1000/ (B/op) 86.58 MB 86.58 MB ⚪ 0%
tree_1000/ (allocs/op) 60,111 allocs 60,113 allocs ⚪ 0%
tree_10000/ (ns/op) 9.68 s 9.62 s 🟢 -0.59%
tree_10000/ (B/op) 8.58 GB 8.58 GB ⚪ 0%
tree_10000/ (allocs/op) 600,173 allocs 600,192 allocs ⚪ 0%
tree_delete_all_1000/ (ns/op) 78.41 ms 82.74 ms 🔴 +5.53%
tree_delete_all_1000/ (B/op) 87.57 MB 87.57 MB ⚪ 0%
tree_delete_all_1000/ (allocs/op) 75,289 allocs 75,293 allocs ⚪ 0%
tree_edit_gc_100/ (ns/op) 3.96 ms 4.18 ms 🔴 +5.50%
tree_edit_gc_100/ (B/op) 4.15 MB 4.15 MB ⚪ 0%
tree_edit_gc_100/ (allocs/op) 15,147 allocs 15,148 allocs ⚪ 0%
tree_edit_gc_1000/ (ns/op) 332.75 ms 344.17 ms 🔴 +3.43%
tree_edit_gc_1000/ (B/op) 384.04 MB 384.05 MB ⚪ 0%
tree_edit_gc_1000/ (allocs/op) 154,952 allocs 154,951 allocs ⚪ 0%
tree_split_gc_100/ (ns/op) 2.67 ms 2.65 ms 🟢 -0.61%
tree_split_gc_100/ (B/op) 2.41 MB 2.41 MB ⚪ 0%
tree_split_gc_100/ (allocs/op) 11,131 allocs 11,132 allocs ⚪ 0%
tree_split_gc_1000/ (ns/op) 197.74 ms 195.29 ms 🟢 -1.24%
tree_split_gc_1000/ (B/op) 222.50 MB 222.50 MB ⚪ 0%
tree_split_gc_1000/ (allocs/op) 122,053 allocs 122,064 allocs ⚪ 0%
BenchmarkRPC
Benchmark suite Previous Current Change
client_to_server/ (ns/op) 431.85 ms 458.65 ms 🔴 +6.21%
client_to_server/ (B/op) 16.13 MB 17.90 MB 🔴 +10.96%
client_to_server/ (allocs/op) 223,674 allocs 223,804 allocs 🔴 +0.06%
client_to_client_via_server/ (ns/op) 788.62 ms 804.16 ms 🔴 +1.97%
client_to_client_via_server/ (B/op) 37.20 MB 40.23 MB 🔴 +8.15%
client_to_client_via_server/ (allocs/op) 478,656 allocs 483,165 allocs 🔴 +0.94%
attach_large_document/ (ns/op) 1.32 s 1.36 s 🔴 +3.06%
attach_large_document/ (B/op) 1.89 GB 1.90 GB 🔴 +0.64%
attach_large_document/ (allocs/op) 12,321 allocs 12,298 allocs 🟢 -0.19%
adminCli_to_server/ (ns/op) 542.08 ms 568.64 ms 🔴 +4.90%
adminCli_to_server/ (B/op) 21.76 MB 21.33 MB 🟢 -1.95%
adminCli_to_server/ (allocs/op) 291,952 allocs 316,679 allocs 🔴 +8.47%
BenchmarkLocker
Benchmark suite Previous Current Change
(ns/op) 82.86 ns 84.94 ns 🔴 +2.51%
(B/op) 32.00 B 32.00 B ⚪ 0%
(allocs/op) 1 allocs 1 allocs ⚪ 0%
BenchmarkLockerParallel
Benchmark suite Previous Current Change
(ns/op) 45.80 ns 47.39 ns 🔴 +3.47%
(B/op) 0.00 B 0.00 B ⚪ 0%
(allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkLockerMoreKeys
Benchmark suite Previous Current Change
(ns/op) 180.50 ns 188.90 ns 🔴 +4.65%
(B/op) 31.00 B 31.00 B ⚪ 0%
(allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkRWLocker
Benchmark suite Previous Current Change
RWLock_rate_2/ (ns/op) 50.25 ns 53.64 ns 🔴 +6.75%
RWLock_rate_2/ (B/op) 0.00 B 0.00 B ⚪ 0%
RWLock_rate_2/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_10/ (ns/op) 44.88 ns 47.19 ns 🔴 +5.15%
RWLock_rate_10/ (B/op) 0.00 B 0.00 B ⚪ 0%
RWLock_rate_10/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_100/ (ns/op) 63.08 ns 62.29 ns 🟢 -1.25%
RWLock_rate_100/ (B/op) 2.00 B 2.00 B ⚪ 0%
RWLock_rate_100/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_1000/ (ns/op) 91.91 ns 90.79 ns 🟢 -1.22%
RWLock_rate_1000/ (B/op) 8.00 B 8.00 B ⚪ 0%
RWLock_rate_1000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkChange
Benchmark suite Previous Current Change
Push_10_Changes/ (ns/op) 4.54 ms 4.69 ms 🔴 +3.29%
Push_10_Changes/ (B/op) 150.42 KB 149.73 KB 🟢 -0.46%
Push_10_Changes/ (allocs/op) 1,623 allocs 1,624 allocs 🔴 +0.06%
Push_100_Changes/ (ns/op) 16.52 ms 17.13 ms 🔴 +3.72%
Push_100_Changes/ (B/op) 770.59 KB 777.82 KB 🔴 +0.94%
Push_100_Changes/ (allocs/op) 8,509 allocs 8,512 allocs 🔴 +0.04%
Push_1000_Changes/ (ns/op) 129.20 ms 129.09 ms 🟢 -0.08%
Push_1000_Changes/ (B/op) 7.22 MB 7.11 MB 🟢 -1.51%
Push_1000_Changes/ (allocs/op) 79,325 allocs 79,324 allocs ⚪ 0%
Pull_10_Changes/ (ns/op) 3.70 ms 3.75 ms 🔴 +1.31%
Pull_10_Changes/ (B/op) 124.59 KB 124.03 KB 🟢 -0.45%
Pull_10_Changes/ (allocs/op) 1,456 allocs 1,454 allocs 🟢 -0.14%
Pull_100_Changes/ (ns/op) 5.32 ms 5.31 ms 🟢 -0.28%
Pull_100_Changes/ (B/op) 354.61 KB 353.46 KB 🟢 -0.32%
Pull_100_Changes/ (allocs/op) 5,182 allocs 5,179 allocs 🟢 -0.06%
Pull_1000_Changes/ (ns/op) 10.88 ms 11.05 ms 🔴 +1.56%
Pull_1000_Changes/ (B/op) 2.20 MB 2.20 MB 🟢 -0.09%
Pull_1000_Changes/ (allocs/op) 44,681 allocs 44,680 allocs ⚪ 0%
BenchmarkSnapshot
Benchmark suite Previous Current Change
Push_3KB_snapshot/ (ns/op) 19.55 ms 18.49 ms 🟢 -5.43%
Push_3KB_snapshot/ (B/op) 905.58 KB 903.31 KB 🟢 -0.25%
Push_3KB_snapshot/ (allocs/op) 8,516 allocs 8,513 allocs 🟢 -0.04%
Push_30KB_snapshot/ (ns/op) 132.18 ms 133.41 ms 🔴 +0.93%
Push_30KB_snapshot/ (B/op) 8.24 MB 8.06 MB 🟢 -2.16%
Push_30KB_snapshot/ (allocs/op) 89,008 allocs 87,363 allocs 🟢 -1.85%
Pull_3KB_snapshot/ (ns/op) 7.80 ms 7.58 ms 🟢 -2.82%
Pull_3KB_snapshot/ (B/op) 1.12 MB 1.06 MB 🟢 -5.02%
Pull_3KB_snapshot/ (allocs/op) 20,064 allocs 19,257 allocs 🟢 -4.02%
Pull_30KB_snapshot/ (ns/op) 19.91 ms 20.17 ms 🔴 +1.27%
Pull_30KB_snapshot/ (B/op) 9.31 MB 8.77 MB 🟢 -5.83%
Pull_30KB_snapshot/ (allocs/op) 193,610 allocs 185,676 allocs 🟢 -4.10%
BenchmarkSplayTree
Benchmark suite Previous Current Change
stress_test_100000/ (ns/op) 0.19 ns 0.19 ns 🟢 -0.88%
stress_test_100000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_100000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
stress_test_200000/ (ns/op) 0.40 ns 0.38 ns 🟢 -3.80%
stress_test_200000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_200000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
stress_test_300000/ (ns/op) 0.57 ns 0.58 ns 🔴 +2.43%
stress_test_300000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_300000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_100000/ (ns/op) 0.01 ns 0.01 ns 🔴 +5.27%
random_access_100000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_100000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_200000/ (ns/op) 0.03 ns 0.03 ns 🟢 -1.10%
random_access_200000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_200000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_300000/ (ns/op) 0.04 ns 0.05 ns 🔴 +11.09%
random_access_300000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_300000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
editing_trace_bench/ (ns/op) 0.00 ns 0.00 ns 🔴 +28.11%
editing_trace_bench/ (B/op) 0.00 B 0.00 B ⚪ 0%
editing_trace_bench/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkSync
Benchmark suite Previous Current Change
memory_sync_10_test/ (ns/op) 7288.00 ns 7511.00 ns 🔴 +3.06%
memory_sync_10_test/ (B/op) 1.34 KB 1.34 KB 🔴 +0.07%
memory_sync_10_test/ (allocs/op) 35 allocs 35 allocs ⚪ 0%
memory_sync_100_test/ (ns/op) 55353.00 ns 54019.00 ns 🟢 -2.41%
memory_sync_100_test/ (B/op) 9.51 KB 9.54 KB 🔴 +0.35%
memory_sync_100_test/ (allocs/op) 268 allocs 269 allocs 🔴 +0.37%
memory_sync_1000_test/ (ns/op) 616285.00 ns 605963.00 ns 🟢 -1.67%
memory_sync_1000_test/ (B/op) 75.92 KB 76.12 KB 🔴 +0.26%
memory_sync_1000_test/ (allocs/op) 2,111 allocs 2,118 allocs 🔴 +0.33%
memory_sync_10000_test/ (ns/op) 7.47 ms 8.78 ms 🔴 +17.51%
memory_sync_10000_test/ (B/op) 761.49 KB 765.57 KB 🔴 +0.54%
memory_sync_10000_test/ (allocs/op) 20,475 allocs 20,575 allocs 🔴 +0.49%
BenchmarkTextEditing
Benchmark suite Previous Current Change
(ns/op) 5.18 s 5.42 s 🔴 +4.66%
(B/op) 3.92 GB 3.92 GB ⚪ 0%
(allocs/op) 20,619,777 allocs 20,619,798 allocs ⚪ 0%
BenchmarkTree
Benchmark suite Previous Current Change
10000_vertices_to_protobuf/ (ns/op) 4.17 ms 4.22 ms 🔴 +1.05%
10000_vertices_to_protobuf/ (B/op) 6.36 MB 6.36 MB ⚪ 0%
10000_vertices_to_protobuf/ (allocs/op) 70,025 allocs 70,025 allocs ⚪ 0%
10000_vertices_from_protobuf/ (ns/op) 217.30 ms 216.69 ms 🟢 -0.28%
10000_vertices_from_protobuf/ (B/op) 442.30 MB 442.30 MB ⚪ 0%
10000_vertices_from_protobuf/ (allocs/op) 290,038 allocs 290,039 allocs ⚪ 0%
20000_vertices_to_protobuf/ (ns/op) 8.84 ms 9.07 ms 🔴 +2.62%
20000_vertices_to_protobuf/ (B/op) 12.89 MB 12.89 MB ⚪ 0%
20000_vertices_to_protobuf/ (allocs/op) 140,028 allocs 140,028 allocs ⚪ 0%
20000_vertices_from_protobuf/ (ns/op) 884.61 ms 900.88 ms 🔴 +1.84%
20000_vertices_from_protobuf/ (B/op) 1.70 GB 1.70 GB ⚪ 0%
20000_vertices_from_protobuf/ (allocs/op) 580,043 allocs 580,044 allocs ⚪ 0%
30000_vertices_to_protobuf/ (ns/op) 14.26 ms 13.98 ms 🟢 -1.97%
30000_vertices_to_protobuf/ (B/op) 18.98 MB 18.98 MB ⚪ 0%
30000_vertices_to_protobuf/ (allocs/op) 210,029 allocs 210,029 allocs ⚪ 0%
30000_vertices_from_protobuf/ (ns/op) 2.00 s 1.99 s 🟢 -0.59%
30000_vertices_from_protobuf/ (B/op) 3.75 GB 3.75 GB ⚪ 0%
30000_vertices_from_protobuf/ (allocs/op) 870,147 allocs 870,138 allocs ⚪ 0%
BenchmarkVersionVector
Benchmark suite Previous Current Change
clients_10/ (ns/op) 160.21 ms 157.67 ms 🟢 -1.58%
clients_10/ (1_changepack(bytes)) 745.00 B 745.00 B ⚪ 0%
clients_10/ (2_snapshot(bytes)) 379.00 B 379.00 B ⚪ 0%
clients_10/ (3_pushpull(ms)) 8.00 ms 7.00 ms 🟢 -12.50%
clients_10/ (4_attach(ms)) 6.00 ms 6.00 ms ⚪ 0%
clients_10/ (5_changepack_after_detach(bytes)) 805.00 B 805.00 B ⚪ 0%
clients_10/ (6_snapshot_after_detach(bytes)) 136.00 B 136.00 B ⚪ 0%
clients_10/ (7_pushpull_after_detach(ms)) 8.00 ms 8.00 ms ⚪ 0%
clients_10/ (B/op) 19.93 MB 20.14 MB 🔴 +1.06%
clients_10/ (allocs/op) 83,762 allocs 83,257 allocs 🟢 -0.60%
clients_100/ (ns/op) 1.41 s 1.40 s 🟢 -0.89%
clients_100/ (1_changepack(bytes)) 6.14 KB 6.14 KB ⚪ 0%
clients_100/ (2_snapshot(bytes)) 3.08 KB 3.08 KB ⚪ 0%
clients_100/ (3_pushpull(ms)) 11.00 ms 12.00 ms 🔴 +9.09%
clients_100/ (4_attach(ms)) 11.00 ms 9.00 ms 🟢 -18.18%
clients_100/ (5_changepack_after_detach(bytes)) 6.21 KB 6.21 KB ⚪ 0%
clients_100/ (6_snapshot_after_detach(bytes)) 137.00 B 137.00 B ⚪ 0%
clients_100/ (7_pushpull_after_detach(ms)) 9.00 ms 9.00 ms ⚪ 0%
clients_100/ (B/op) 230.31 MB 216.79 MB 🟢 -5.87%
clients_100/ (allocs/op) 1,539,768 allocs 1,481,361 allocs 🟢 -3.79%
clients_1000/ (ns/op) 60.97 s 44.68 s 🟢 -26.72%
clients_1000/ (1_changepack(bytes)) 60.16 KB 60.16 KB ⚪ 0%
clients_1000/ (2_snapshot(bytes)) 30.08 KB 30.08 KB ⚪ 0%
clients_1000/ (3_pushpull(ms)) 95.00 ms 116.00 ms 🔴 +22.11%
clients_1000/ (4_attach(ms)) 249.00 ms 74.00 ms 🟢 -70.28%
clients_1000/ (5_changepack_after_detach(bytes)) 60.22 KB 60.22 KB ⚪ 0%
clients_1000/ (6_snapshot_after_detach(bytes)) 139.00 B 139.00 B ⚪ 0%
clients_1000/ (7_pushpull_after_detach(ms)) 26.00 ms 23.00 ms 🟢 -11.54%
clients_1000/ (B/op) 22.07 GB 6.43 GB 🟢 -70.85%
clients_1000/ (allocs/op) 111,762,106 allocs 93,353,673 allocs 🟢 -16.47%

@hackerwins
Copy link
Member

The signatures of Min and Max methods returning a VersionVector give the impression that they create new objects(similar to how immutable types typically work). What if we change them to not return anything at all?

Copy link

@hackerwins-yorkie hackerwins-yorkie left a comment

Choose a reason for hiding this comment

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

Go Benchmark Analysis 📊

This is a comparison result between the previous(e687d61) and the current commit(8709152).

Significant Changes (≥20% difference)

Benchmark suite Previous Current Change
BenchmarkVersionVector/clients_1000/ (B/op) 22.07 GB 6.43 GB 🟢 -70.85%
BenchmarkVersionVector/clients_1000/ (4_attach(ms)) 249.00 ms 74.00 ms 🟢 -70.28%
BenchmarkVersionVector/clients_1000/ (ns/op) 60.97 s 44.54 s 🟢 -26.95%
BenchmarkVersionVector/clients_1000/ (3_pushpull(ms)) 95.00 ms 116.00 ms 🔴 +22.11%
BenchmarkSplayTree/editing_trace_bench/ (ns/op) 0.00 ns 0.00 ns 🔴 +20.07%

Key Observations 🔍

  • The BenchmarkVersionVector/clients_1000/ suite showed significant improvements:

    • The B/op metric decreased by a substantial 70.85%, indicating a significant reduction in memory consumption.
    • The 4_attach(ms) metric also improved by 70.28%, suggesting a notable enhancement in attachment processing speed.
    • Notably, the ns/op metric saw a 26.95% decrease, indicating an improvement in the time efficiency of client operations.
  • The BenchmarkSnapshot suite exhibited noteworthy changes:

    • There were improvements in various sub-tests:
      • The Pull_3KB_snapshot/ showed a reduction in both ns/op and B/op, indicating better performance and reduced memory usage.
      • Conversely, the Push_30KB_snapshot/ metric increased by 3.01% in ns/op, suggesting a slight decrease in processing efficiency for pushing larger snapshots.
  • Overall Trends:

    • Across different benchmarks, there were both positive and negative changes, showcasing a dynamic performance shift in various test scenarios.
    • Some benchmarks displayed consistent improvements in performance metrics, while others showed fluctuations in memory utilization and processing speeds.

Given the diverse nature of the benchmark data, it's crucial to continue monitoring these metrics to track performance trends accurately.

Clock Analysis

Lamport (v0.5.2)

Metric 10 clients 100 clients 1000 clients
Total Operation Time 84.96 ms 793.94 ms 34.79 s
Memory Allocations 35.11 MB 219.92 MB 4.91 GB
Number of Allocations (allocs/op) 69,271 1,246,728 81,485,288
ChangePack Size 138.0 B 137.0 B 141.0 B
Snapshot Size 379.0 B 3.08 KB 30.08 KB
Push-Pull Time 2.0 ms 1.5 ms 4.0 ms
Attach Time 4.5 ms 11.0 ms 31.0 ms
ChangePack After Detach 138.0 B 140.0 B 141.0 B
Snapshot After Detach 136.0 B 137.0 B 139.0 B
Push-Pull After Detach 2.5 ms 5.0 ms 9.5 ms

VV (current)

Metric 10 clients 100 clients 1000 clients
Total Operation Time 160.15 ms 1.44 s 44.54 s
Memory Allocations 20.02 MB 214.23 MB 6.43 GB
Number of Allocations (allocs/op) 83,262 1,481,500 93,354,616
ChangePack Size 745.00 B 6.14 KB 60.16 KB
Snapshot Size 379.00 B 3.08 KB 30.08 KB
Push-Pull Time 8.00 ms 12.0 ms 116.0 ms
Attach Time 6.00 ms 10.0 ms 74.0 ms
ChangePack After Detach 805.00 B 6.21 KB 60.22 KB
Snapshot After Detach 136.00 B 137.00 B 139.00 B
Push-Pull After Detach 8.00 ms 9.00 ms 25.00 ms

Summary

  • The Lamport clock generally outperforms the Version Vector in terms of total operation time across all client counts.
  • However, the Version Vector shows significant improvements in memory allocations for 1000 clients, indicating better memory efficiency.
  • In terms of specific operations like Push-Pull Time and Attach Time, the Lamport clock exhibits lower times compared to the Version Vector.
  • The Version Vector shows better performance in ChangePack Size and post-detach operations for all client counts.

Detailed Test Results

BenchmarkDocument
Benchmark suite Previous Current Change
constructor_test/ (ns/op) 1439.00 ns 1482.00 ns 🔴 +2.99%
constructor_test/ (B/op) 1.39 KB 1.43 KB 🔴 +3.47%
constructor_test/ (allocs/op) 24 allocs 25 allocs 🔴 +4.17%
status_test/ (ns/op) 1028.00 ns 1093.00 ns 🔴 +6.32%
status_test/ (B/op) 1.35 KB 1.40 KB 🔴 +3.55%
status_test/ (allocs/op) 22 allocs 23 allocs 🔴 +4.55%
equals_test/ (ns/op) 7864.00 ns 8029.00 ns 🔴 +2.10%
equals_test/ (B/op) 7.56 KB 7.71 KB 🔴 +1.90%
equals_test/ (allocs/op) 129 allocs 132 allocs 🔴 +2.33%
nested_update_test/ (ns/op) 17079.00 ns 17082.00 ns 🔴 +0.02%
nested_update_test/ (B/op) 12.31 KB 12.36 KB 🔴 +0.39%
nested_update_test/ (allocs/op) 258 allocs 259 allocs 🔴 +0.39%
delete_test/ (ns/op) 27313.00 ns 24173.00 ns 🟢 -11.50%
delete_test/ (B/op) 15.79 KB 15.84 KB 🔴 +0.30%
delete_test/ (allocs/op) 339 allocs 340 allocs 🔴 +0.29%
object_test/ (ns/op) 8546.00 ns 9856.00 ns 🔴 +15.33%
object_test/ (B/op) 7.03 KB 7.08 KB 🔴 +0.68%
object_test/ (allocs/op) 118 allocs 119 allocs 🔴 +0.85%
array_test/ (ns/op) 28984.00 ns 29408.00 ns 🔴 +1.46%
array_test/ (B/op) 12.14 KB 12.19 KB 🔴 +0.40%
array_test/ (allocs/op) 273 allocs 274 allocs 🔴 +0.37%
text_test/ (ns/op) 32155.00 ns 32272.00 ns 🔴 +0.36%
text_test/ (B/op) 15.19 KB 15.24 KB 🔴 +0.32%
text_test/ (allocs/op) 484 allocs 485 allocs 🔴 +0.21%
text_composition_test/ (ns/op) 31674.00 ns 31960.00 ns 🔴 +0.90%
text_composition_test/ (B/op) 18.70 KB 18.75 KB 🔴 +0.26%
text_composition_test/ (allocs/op) 501 allocs 502 allocs 🔴 +0.20%
rich_text_test/ (ns/op) 87424.00 ns 86299.00 ns 🟢 -1.29%
rich_text_test/ (B/op) 39.36 KB 39.40 KB 🔴 +0.11%
rich_text_test/ (allocs/op) 1,146 allocs 1,147 allocs 🔴 +0.09%
counter_test/ (ns/op) 18201.00 ns 18327.00 ns 🔴 +0.69%
counter_test/ (B/op) 11.81 KB 11.86 KB 🔴 +0.41%
counter_test/ (allocs/op) 253 allocs 254 allocs 🔴 +0.40%
text_edit_gc_100/ (ns/op) 1.39 ms 1.40 ms 🔴 +1.04%
text_edit_gc_100/ (B/op) 864.90 KB 864.91 KB ⚪ 0%
text_edit_gc_100/ (allocs/op) 17,281 allocs 17,283 allocs 🔴 +0.01%
text_edit_gc_1000/ (ns/op) 53.39 ms 53.07 ms 🟢 -0.61%
text_edit_gc_1000/ (B/op) 46.84 MB 46.84 MB ⚪ 0%
text_edit_gc_1000/ (allocs/op) 185,598 allocs 185,585 allocs ⚪ 0%
text_split_gc_100/ (ns/op) 2.12 ms 2.12 ms 🔴 +0.10%
text_split_gc_100/ (B/op) 1.58 MB 1.58 MB ⚪ 0%
text_split_gc_100/ (allocs/op) 15,950 allocs 15,951 allocs ⚪ 0%
text_split_gc_1000/ (ns/op) 128.25 ms 130.68 ms 🔴 +1.90%
text_split_gc_1000/ (B/op) 137.79 MB 137.79 MB ⚪ 0%
text_split_gc_1000/ (allocs/op) 185,000 allocs 184,993 allocs ⚪ 0%
text_delete_all_10000/ (ns/op) 18.43 ms 18.16 ms 🟢 -1.51%
text_delete_all_10000/ (B/op) 10.58 MB 10.58 MB 🔴 +0.01%
text_delete_all_10000/ (allocs/op) 56,134 allocs 56,135 allocs ⚪ 0%
text_delete_all_100000/ (ns/op) 312.31 ms 323.33 ms 🔴 +3.53%
text_delete_all_100000/ (B/op) 105.54 MB 105.55 MB ⚪ 0%
text_delete_all_100000/ (allocs/op) 566,133 allocs 566,038 allocs 🟢 -0.02%
text_100/ (ns/op) 234634.00 ns 233399.00 ns 🟢 -0.53%
text_100/ (B/op) 120.94 KB 120.95 KB 🔴 +0.01%
text_100/ (allocs/op) 5,181 allocs 5,182 allocs 🔴 +0.02%
text_1000/ (ns/op) 2.46 ms 2.52 ms 🔴 +2.13%
text_1000/ (B/op) 1.16 MB 1.16 MB ⚪ 0%
text_1000/ (allocs/op) 51,084 allocs 51,085 allocs ⚪ 0%
array_1000/ (ns/op) 1.24 ms 1.25 ms 🔴 +0.42%
array_1000/ (B/op) 1.09 MB 1.09 MB ⚪ 0%
array_1000/ (allocs/op) 11,879 allocs 11,880 allocs ⚪ 0%
array_10000/ (ns/op) 13.33 ms 13.33 ms 🟢 -0.05%
array_10000/ (B/op) 9.89 MB 9.89 MB 🟢 -0.01%
array_10000/ (allocs/op) 120,735 allocs 120,733 allocs ⚪ 0%
array_gc_100/ (ns/op) 131750.00 ns 134454.00 ns 🔴 +2.05%
array_gc_100/ (B/op) 99.89 KB 99.94 KB 🔴 +0.05%
array_gc_100/ (allocs/op) 1,266 allocs 1,267 allocs 🔴 +0.08%
array_gc_1000/ (ns/op) 1.42 ms 1.43 ms 🔴 +0.47%
array_gc_1000/ (B/op) 1.14 MB 1.14 MB 🔴 +0.01%
array_gc_1000/ (allocs/op) 12,926 allocs 12,928 allocs 🔴 +0.02%
counter_1000/ (ns/op) 202098.00 ns 205035.00 ns 🔴 +1.45%
counter_1000/ (B/op) 178.13 KB 178.18 KB 🔴 +0.03%
counter_1000/ (allocs/op) 5,771 allocs 5,772 allocs 🔴 +0.02%
counter_10000/ (ns/op) 2.17 ms 2.19 ms 🔴 +0.93%
counter_10000/ (B/op) 2.07 MB 2.07 MB ⚪ 0%
counter_10000/ (allocs/op) 59,778 allocs 59,779 allocs ⚪ 0%
object_1000/ (ns/op) 1.39 ms 1.44 ms 🔴 +3.91%
object_1000/ (B/op) 1.44 MB 1.44 MB 🔴 +0.01%
object_1000/ (allocs/op) 9,925 allocs 9,926 allocs 🔴 +0.01%
object_10000/ (ns/op) 14.82 ms 15.01 ms 🔴 +1.27%
object_10000/ (B/op) 12.35 MB 12.35 MB ⚪ 0%
object_10000/ (allocs/op) 101,232 allocs 101,232 allocs ⚪ 0%
tree_100/ (ns/op) 1.02 ms 1.03 ms 🔴 +0.56%
tree_100/ (B/op) 951.02 KB 951.08 KB ⚪ 0%
tree_100/ (allocs/op) 6,102 allocs 6,103 allocs 🔴 +0.02%
tree_1000/ (ns/op) 74.23 ms 76.33 ms 🔴 +2.83%
tree_1000/ (B/op) 86.58 MB 86.58 MB ⚪ 0%
tree_1000/ (allocs/op) 60,111 allocs 60,113 allocs ⚪ 0%
tree_10000/ (ns/op) 9.68 s 9.83 s 🔴 +1.60%
tree_10000/ (B/op) 8.58 GB 8.58 GB ⚪ 0%
tree_10000/ (allocs/op) 600,173 allocs 600,191 allocs ⚪ 0%
tree_delete_all_1000/ (ns/op) 78.41 ms 78.13 ms 🟢 -0.36%
tree_delete_all_1000/ (B/op) 87.57 MB 87.57 MB ⚪ 0%
tree_delete_all_1000/ (allocs/op) 75,289 allocs 75,290 allocs ⚪ 0%
tree_edit_gc_100/ (ns/op) 3.96 ms 3.87 ms 🟢 -2.32%
tree_edit_gc_100/ (B/op) 4.15 MB 4.15 MB ⚪ 0%
tree_edit_gc_100/ (allocs/op) 15,147 allocs 15,147 allocs ⚪ 0%
tree_edit_gc_1000/ (ns/op) 332.75 ms 316.92 ms 🟢 -4.76%
tree_edit_gc_1000/ (B/op) 384.04 MB 384.04 MB ⚪ 0%
tree_edit_gc_1000/ (allocs/op) 154,952 allocs 154,940 allocs ⚪ 0%
tree_split_gc_100/ (ns/op) 2.67 ms 2.61 ms 🟢 -2.11%
tree_split_gc_100/ (B/op) 2.41 MB 2.41 MB ⚪ 0%
tree_split_gc_100/ (allocs/op) 11,131 allocs 11,132 allocs ⚪ 0%
tree_split_gc_1000/ (ns/op) 197.74 ms 192.74 ms 🟢 -2.53%
tree_split_gc_1000/ (B/op) 222.50 MB 222.50 MB ⚪ 0%
tree_split_gc_1000/ (allocs/op) 122,053 allocs 122,069 allocs 🔴 +0.01%
BenchmarkRPC
Benchmark suite Previous Current Change
client_to_server/ (ns/op) 431.85 ms 427.06 ms 🟢 -1.11%
client_to_server/ (B/op) 16.13 MB 17.94 MB 🔴 +11.22%
client_to_server/ (allocs/op) 223,674 allocs 223,718 allocs 🔴 +0.02%
client_to_client_via_server/ (ns/op) 788.62 ms 799.37 ms 🔴 +1.36%
client_to_client_via_server/ (B/op) 37.20 MB 37.70 MB 🔴 +1.35%
client_to_client_via_server/ (allocs/op) 478,656 allocs 477,115 allocs 🟢 -0.32%
attach_large_document/ (ns/op) 1.32 s 1.47 s 🔴 +11.19%
attach_large_document/ (B/op) 1.89 GB 1.90 GB 🔴 +0.64%
attach_large_document/ (allocs/op) 12,321 allocs 12,465 allocs 🔴 +1.17%
adminCli_to_server/ (ns/op) 542.08 ms 561.25 ms 🔴 +3.54%
adminCli_to_server/ (B/op) 21.76 MB 21.31 MB 🟢 -2.03%
adminCli_to_server/ (allocs/op) 291,952 allocs 316,696 allocs 🔴 +8.48%
BenchmarkLocker
Benchmark suite Previous Current Change
(ns/op) 82.86 ns 86.23 ns 🔴 +4.07%
(B/op) 32.00 B 32.00 B ⚪ 0%
(allocs/op) 1 allocs 1 allocs ⚪ 0%
BenchmarkLockerParallel
Benchmark suite Previous Current Change
(ns/op) 45.80 ns 54.00 ns 🔴 +17.90%
(B/op) 0.00 B 0.00 B ⚪ 0%
(allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkLockerMoreKeys
Benchmark suite Previous Current Change
(ns/op) 180.50 ns 191.60 ns 🔴 +6.15%
(B/op) 31.00 B 30.00 B 🟢 -3.23%
(allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkRWLocker
Benchmark suite Previous Current Change
RWLock_rate_2/ (ns/op) 50.25 ns 55.68 ns 🔴 +10.81%
RWLock_rate_2/ (B/op) 0.00 B 0.00 B ⚪ 0%
RWLock_rate_2/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_10/ (ns/op) 44.88 ns 51.49 ns 🔴 +14.73%
RWLock_rate_10/ (B/op) 0.00 B 0.00 B ⚪ 0%
RWLock_rate_10/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_100/ (ns/op) 63.08 ns 70.99 ns 🔴 +12.54%
RWLock_rate_100/ (B/op) 2.00 B 2.00 B ⚪ 0%
RWLock_rate_100/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
RWLock_rate_1000/ (ns/op) 91.91 ns 103.70 ns 🔴 +12.83%
RWLock_rate_1000/ (B/op) 8.00 B 9.00 B 🔴 +12.50%
RWLock_rate_1000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkChange
Benchmark suite Previous Current Change
Push_10_Changes/ (ns/op) 4.54 ms 4.65 ms 🔴 +2.44%
Push_10_Changes/ (B/op) 150.42 KB 150.44 KB 🔴 +0.01%
Push_10_Changes/ (allocs/op) 1,623 allocs 1,625 allocs 🔴 +0.12%
Push_100_Changes/ (ns/op) 16.52 ms 16.81 ms 🔴 +1.77%
Push_100_Changes/ (B/op) 770.59 KB 780.19 KB 🔴 +1.25%
Push_100_Changes/ (allocs/op) 8,509 allocs 8,512 allocs 🔴 +0.04%
Push_1000_Changes/ (ns/op) 129.20 ms 133.37 ms 🔴 +3.23%
Push_1000_Changes/ (B/op) 7.22 MB 7.29 MB 🔴 +1.02%
Push_1000_Changes/ (allocs/op) 79,325 allocs 79,322 allocs ⚪ 0%
Pull_10_Changes/ (ns/op) 3.70 ms 3.73 ms 🔴 +0.83%
Pull_10_Changes/ (B/op) 124.59 KB 124.24 KB 🟢 -0.28%
Pull_10_Changes/ (allocs/op) 1,456 allocs 1,454 allocs 🟢 -0.14%
Pull_100_Changes/ (ns/op) 5.32 ms 5.38 ms 🔴 +0.97%
Pull_100_Changes/ (B/op) 354.61 KB 353.58 KB 🟢 -0.29%
Pull_100_Changes/ (allocs/op) 5,182 allocs 5,179 allocs 🟢 -0.06%
Pull_1000_Changes/ (ns/op) 10.88 ms 11.23 ms 🔴 +3.27%
Pull_1000_Changes/ (B/op) 2.20 MB 2.20 MB 🟢 -0.16%
Pull_1000_Changes/ (allocs/op) 44,681 allocs 44,679 allocs ⚪ 0%
BenchmarkSnapshot
Benchmark suite Previous Current Change
Push_3KB_snapshot/ (ns/op) 19.55 ms 19.12 ms 🟢 -2.23%
Push_3KB_snapshot/ (B/op) 905.58 KB 897.40 KB 🟢 -0.90%
Push_3KB_snapshot/ (allocs/op) 8,516 allocs 8,516 allocs ⚪ 0%
Push_30KB_snapshot/ (ns/op) 132.18 ms 136.15 ms 🔴 +3.01%
Push_30KB_snapshot/ (B/op) 8.24 MB 8.01 MB 🟢 -2.79%
Push_30KB_snapshot/ (allocs/op) 89,008 allocs 86,996 allocs 🟢 -2.26%
Pull_3KB_snapshot/ (ns/op) 7.80 ms 7.46 ms 🟢 -4.38%
Pull_3KB_snapshot/ (B/op) 1.12 MB 1.06 MB 🟢 -5.04%
Pull_3KB_snapshot/ (allocs/op) 20,064 allocs 19,255 allocs 🟢 -4.03%
Pull_30KB_snapshot/ (ns/op) 19.91 ms 19.66 ms 🟢 -1.27%
Pull_30KB_snapshot/ (B/op) 9.31 MB 8.76 MB 🟢 -5.88%
Pull_30KB_snapshot/ (allocs/op) 193,610 allocs 185,672 allocs 🟢 -4.10%
BenchmarkSplayTree
Benchmark suite Previous Current Change
stress_test_100000/ (ns/op) 0.19 ns 0.19 ns 🟢 -0.10%
stress_test_100000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_100000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
stress_test_200000/ (ns/op) 0.40 ns 0.39 ns 🟢 -0.38%
stress_test_200000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_200000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
stress_test_300000/ (ns/op) 0.57 ns 0.59 ns 🔴 +3.13%
stress_test_300000/ (B/op) 0.00 B 0.00 B ⚪ 0%
stress_test_300000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_100000/ (ns/op) 0.01 ns 0.01 ns 🔴 +3.15%
random_access_100000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_100000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_200000/ (ns/op) 0.03 ns 0.03 ns 🟢 -8.42%
random_access_200000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_200000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
random_access_300000/ (ns/op) 0.04 ns 0.04 ns 🟢 -1.24%
random_access_300000/ (B/op) 0.00 B 0.00 B ⚪ 0%
random_access_300000/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
editing_trace_bench/ (ns/op) 0.00 ns 0.00 ns 🔴 +20.07%
editing_trace_bench/ (B/op) 0.00 B 0.00 B ⚪ 0%
editing_trace_bench/ (allocs/op) 0 allocs 0 allocs ⚪ 0%
BenchmarkSync
Benchmark suite Previous Current Change
memory_sync_10_test/ (ns/op) 7288.00 ns 7570.00 ns 🔴 +3.87%
memory_sync_10_test/ (B/op) 1.34 KB 1.34 KB ⚪ 0%
memory_sync_10_test/ (allocs/op) 35 allocs 35 allocs ⚪ 0%
memory_sync_100_test/ (ns/op) 55353.00 ns 57698.00 ns 🔴 +4.24%
memory_sync_100_test/ (B/op) 9.51 KB 9.50 KB 🟢 -0.05%
memory_sync_100_test/ (allocs/op) 268 allocs 268 allocs ⚪ 0%
memory_sync_1000_test/ (ns/op) 616285.00 ns 616220.00 ns 🟢 -0.01%
memory_sync_1000_test/ (B/op) 75.92 KB 75.85 KB 🟢 -0.09%
memory_sync_1000_test/ (allocs/op) 2,111 allocs 2,109 allocs 🟢 -0.09%
memory_sync_10000_test/ (ns/op) 7.47 ms 8.96 ms 🔴 +19.94%
memory_sync_10000_test/ (B/op) 761.49 KB 759.48 KB 🟢 -0.26%
memory_sync_10000_test/ (allocs/op) 20,475 allocs 20,452 allocs 🟢 -0.11%
BenchmarkTextEditing
Benchmark suite Previous Current Change
(ns/op) 5.18 s 5.49 s 🔴 +6.07%
(B/op) 3.92 GB 3.92 GB ⚪ 0%
(allocs/op) 20,619,777 allocs 20,619,766 allocs ⚪ 0%
BenchmarkTree
Benchmark suite Previous Current Change
10000_vertices_to_protobuf/ (ns/op) 4.17 ms 4.32 ms 🔴 +3.45%
10000_vertices_to_protobuf/ (B/op) 6.36 MB 6.36 MB ⚪ 0%
10000_vertices_to_protobuf/ (allocs/op) 70,025 allocs 70,025 allocs ⚪ 0%
10000_vertices_from_protobuf/ (ns/op) 217.30 ms 229.99 ms 🔴 +5.84%
10000_vertices_from_protobuf/ (B/op) 442.30 MB 442.30 MB ⚪ 0%
10000_vertices_from_protobuf/ (allocs/op) 290,038 allocs 290,039 allocs ⚪ 0%
20000_vertices_to_protobuf/ (ns/op) 8.84 ms 9.23 ms 🔴 +4.50%
20000_vertices_to_protobuf/ (B/op) 12.89 MB 12.89 MB ⚪ 0%
20000_vertices_to_protobuf/ (allocs/op) 140,028 allocs 140,028 allocs ⚪ 0%
20000_vertices_from_protobuf/ (ns/op) 884.61 ms 899.65 ms 🔴 +1.70%
20000_vertices_from_protobuf/ (B/op) 1.70 GB 1.70 GB ⚪ 0%
20000_vertices_from_protobuf/ (allocs/op) 580,043 allocs 580,043 allocs ⚪ 0%
30000_vertices_to_protobuf/ (ns/op) 14.26 ms 14.78 ms 🔴 +3.66%
30000_vertices_to_protobuf/ (B/op) 18.98 MB 18.98 MB ⚪ 0%
30000_vertices_to_protobuf/ (allocs/op) 210,029 allocs 210,030 allocs ⚪ 0%
30000_vertices_from_protobuf/ (ns/op) 2.00 s 1.99 s 🟢 -0.38%
30000_vertices_from_protobuf/ (B/op) 3.75 GB 3.75 GB ⚪ 0%
30000_vertices_from_protobuf/ (allocs/op) 870,147 allocs 870,049 allocs 🟢 -0.01%
BenchmarkVersionVector
Benchmark suite Previous Current Change
clients_10/ (ns/op) 160.21 ms 160.15 ms 🟢 -0.04%
clients_10/ (1_changepack(bytes)) 745.00 B 745.00 B ⚪ 0%
clients_10/ (2_snapshot(bytes)) 379.00 B 379.00 B ⚪ 0%
clients_10/ (3_pushpull(ms)) 8.00 ms 8.00 ms ⚪ 0%
clients_10/ (4_attach(ms)) 6.00 ms 6.00 ms ⚪ 0%
clients_10/ (5_changepack_after_detach(bytes)) 805.00 B 805.00 B ⚪ 0%
clients_10/ (6_snapshot_after_detach(bytes)) 136.00 B 136.00 B ⚪ 0%
clients_10/ (7_pushpull_after_detach(ms)) 8.00 ms 8.00 ms ⚪ 0%
clients_10/ (B/op) 19.93 MB 20.02 MB 🔴 +0.45%
clients_10/ (allocs/op) 83,762 allocs 83,262 allocs 🟢 -0.60%
clients_100/ (ns/op) 1.41 s 1.44 s 🔴 +1.91%
clients_100/ (1_changepack(bytes)) 6.14 KB 6.14 KB ⚪ 0%
clients_100/ (2_snapshot(bytes)) 3.08 KB 3.08 KB ⚪ 0%
clients_100/ (3_pushpull(ms)) 11.00 ms 12.00 ms 🔴 +9.09%
clients_100/ (4_attach(ms)) 11.00 ms 10.00 ms 🟢 -9.09%
clients_100/ (5_changepack_after_detach(bytes)) 6.21 KB 6.21 KB ⚪ 0%
clients_100/ (6_snapshot_after_detach(bytes)) 137.00 B 137.00 B ⚪ 0%
clients_100/ (7_pushpull_after_detach(ms)) 9.00 ms 9.00 ms ⚪ 0%
clients_100/ (B/op) 230.31 MB 214.23 MB 🟢 -6.98%
clients_100/ (allocs/op) 1,539,768 allocs 1,481,500 allocs 🟢 -3.78%
clients_1000/ (ns/op) 60.97 s 44.54 s 🟢 -26.95%
clients_1000/ (1_changepack(bytes)) 60.16 KB 60.16 KB ⚪ 0%
clients_1000/ (2_snapshot(bytes)) 30.08 KB 30.08 KB ⚪ 0%
clients_1000/ (3_pushpull(ms)) 95.00 ms 116.00 ms 🔴 +22.11%
clients_1000/ (4_attach(ms)) 249.00 ms 74.00 ms 🟢 -70.28%
clients_1000/ (5_changepack_after_detach(bytes)) 60.22 KB 60.22 KB ⚪ 0%
clients_1000/ (6_snapshot_after_detach(bytes)) 139.00 B 139.00 B ⚪ 0%
clients_1000/ (7_pushpull_after_detach(ms)) 26.00 ms 25.00 ms 🟢 -3.85%
clients_1000/ (B/op) 22.07 GB 6.43 GB 🟢 -70.85%
clients_1000/ (allocs/op) 111,762,106 allocs 93,354,616 allocs 🟢 -16.47%

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 16 lines in your changes missing coverage. Please review.

Project coverage is 38.28%. Comparing base (2fd75be) to head (dc7ee81).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
server/backend/database/memory/database.go 0.00% 5 Missing ⚠️
server/backend/database/mongo/client.go 0.00% 5 Missing ⚠️
pkg/document/change/id.go 0.00% 4 Missing ⚠️
pkg/document/time/version_vector.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1170      +/-   ##
==========================================
- Coverage   38.32%   38.28%   -0.05%     
==========================================
  Files         172      171       -1     
  Lines       25803    25775      -28     
==========================================
- Hits         9890     9867      -23     
+ Misses      15079    15075       -4     
+ Partials      834      833       -1     

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

@hackerwins hackerwins changed the title Refactor version vector comparisons to use in-place Min() method Update VersionVector Operations for In-Place Comparison Feb 28, 2025
@hackerwins hackerwins merged commit d40b3b8 into main Feb 28, 2025
5 checks passed
@hackerwins hackerwins deleted the refactor-minvv branch February 28, 2025 00:29
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.

4 participants