DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Hardware Optimization: Best Practices for Database Performance Boost
  • Slimming Down Your CDI Memory Footprint
  • Decoding Business Source Licensing: A New Software Licensing Model
  • Cutting Big Data Costs: Effective Data Processing With Apache Spark

Trending

  • Build a Serverless App Fast With Zipper: Write TypeScript, Offload Everything Else
  • How To Verify Database Connection From a Spring Boot Application
  • The Convergence of Testing and Observability
  • How To Validate Archives and Identify Invalid Documents in Java
  1. DZone
  2. Software Design and Architecture
  3. Performance
  4. Excerpts from the RavenDB Performance Team Report: Optimizing Memory Comparisons, Size Does Matter

Excerpts from the RavenDB Performance Team Report: Optimizing Memory Comparisons, Size Does Matter

Oren Eini user avatar by
Oren Eini
·
Feb. 19, 15 · Interview
Like (0)
Save
Tweet
Share
3.39K Views

Join the DZone community and get the full member experience.

Join For Free

note, this post was written by federico . in the previous post after inspecting the decompiled source using ilspy  we were able to uncover potential things we could do. in this fragment we have a pretty optimized method to compare an entire 4 bytes per loop. what if we could do that on 8 bytes?

to achieve that we will use a ulong instead of a uint. this type of optimization makes sense for 2 reasons.

most of our users are already running ravendb in x64 where the native word is 8 bytes and voron is compiled on x64 only. but even if that were not true, since the late 2000’ most cpus would have a 64 bytes l1 cache line with half a cycle cost for a hit. so even if you can’t handle 64 bits in one go and the jit or processor have to issue 2 instructions you are still getting a l1 cache hit and no pipeline stall. which is great smile .

so without farther ado, this is the resulting code:

image

ayende’s note: in the code, the lp += (intptr)8/8; is actually defined as lp += 1; what is actually happening is that we are increasing by 8 bytes (size of ulong), and this is how ilspy decided to represent that for some reason.

the actual il generated for this is good:

image

it is just that the translation here is kind of strange.

therefore the question to ask here is: will skipping over the parts of the memory block that is equal at a faster rate will compensate for the cost of doing a final check with 8  bytes instead of 4 bytes?

well the answer is a resounding yes. it won’t have much impact in the first 32 bytes (around 3% or less). we won’t lose, but we won’t win much either. but after that it skyrocket.

// bandwidth optimization kicks in
size:  32 original:  535 optimized:  442 gain:  5.01%
size:  64 original:  607 optimized:  493 gain:  7.08%
size:  128 original:  752 optimized:  573 gain:  11.77%
size:  256 original: 1,080 optimized:  695 gain:  35.69%
size:  512 original: 1,837 optimized:  943 gain:  74.40%
size: 1,024 original: 3,200 optimized: 1,317 gain: 122.25%
size: 2,048 original: 5,135 optimized: 2,110 gain: 123.13%
size: 4,096 original: 8,753 optimized: 3,690 gain: 117.29%

those are real measurements. you can see that when bandwidth optimization kicks in the gains start to get really high. this means that changing the bandwidth size alone from 4 byte to 8 bytes got us an order of magnitude improvement stabilizing around 120%.

not bad for 2 lines of work.

optimization Memory (storage engine)

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Hardware Optimization: Best Practices for Database Performance Boost
  • Slimming Down Your CDI Memory Footprint
  • Decoding Business Source Licensing: A New Software Licensing Model
  • Cutting Big Data Costs: Effective Data Processing With Apache Spark

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: