Skip to content

perf(buffer_object): use madvise for kernel memory hints#8

Draft
g-husam wants to merge 1 commit intomainfrom
mmap-madvise
Draft

perf(buffer_object): use madvise for kernel memory hints#8
g-husam wants to merge 1 commit intomainfrom
mmap-madvise

Conversation

@g-husam
Copy link
Collaborator

@g-husam g-husam commented Jan 23, 2026

No description provided.

@g-husam
Copy link
Collaborator Author

g-husam commented Jan 29, 2026

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request focuses on enhancing the performance of memory-mapped file operations within the buffer_object component. By leveraging the madvise system call, the changes provide crucial hints to the kernel regarding anticipated memory access patterns and preferences for huge pages. This optimization is expected to lead to more efficient memory management, reduced latency, and improved overall throughput for applications utilizing these memory-mapped files.

Highlights

  • Performance Optimization: Introduced madvise system calls after mmap operations to provide kernel memory hints, aiming to improve performance for memory-mapped files.
  • Kernel Memory Hints: Specifically used MADV_WILLNEED to suggest that memory regions will be accessed soon, allowing the kernel to prefetch pages, and MADV_HUGEPAGE to encourage the use of huge pages, which can reduce TLB misses and enhance throughput.
  • Applicability: The madvise calls were added to both create_file_and_mmap (for read/write access) and open_file_and_mmap_ro (for read-only access) functions, ensuring performance benefits across different file access patterns.

🧠 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
  • src/ml_flashpoint/checkpoint_object_manager/buffer_object/buffer_helper.cpp
    • Added madvise(ptr, size, MADV_WILLNEED | MADV_HUGEPAGE); after the mmap call in create_file_and_mmap to provide kernel memory hints for newly created and mapped files.
    • Added madvise(ptr, size, MADV_WILLNEED | MADV_HUGEPAGE); after the mmap call in open_file_and_mmap_ro to provide kernel memory hints for existing read-only mapped files.
    • Corrected a minor formatting issue by ensuring a newline at the end of the file.
Activity
  • g-husam requested a summary of the pull request.

@github-actions
Copy link

Python Code Coverage Summary

Code Coverage

Package Line Rate Branch Rate Health
src.ml_flashpoint 100% 100%
src.ml_flashpoint.adapter 100% 100%
src.ml_flashpoint.adapter.megatron 97% 93%
src.ml_flashpoint.adapter.nemo 98% 95%
src.ml_flashpoint.adapter.pytorch 99% 88%
src.ml_flashpoint.checkpoint_object_manager 94% 92%
src.ml_flashpoint.core 96% 92%
src.ml_flashpoint.replication 81% 81%
Summary 95% (2028 / 2134) 91% (470 / 516)

Minimum allowed line rate is 90%

@github-actions
Copy link

C++ Code Coverage Summary

Code Coverage

Package Line Rate Branch Rate Health
src.ml_flashpoint.checkpoint_object_manager.buffer_object 94% 54%
src.ml_flashpoint.checkpoint_object_manager.object_manager 70% 37%
src.ml_flashpoint.replication.transfer_service 79% 40%
Summary 81% (890 / 1096) 42% (660 / 1554)

Minimum allowed line rate is 80%

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.

1 participant