SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Multithreading aware Storage

        PATCH DESCRIPTION
Goals

 Make Storage and Buffering Managers
  multithreading-safe
 Improve performance by allowing simultaneous
  operations
 Provide flexible compile-time options to select
  optimal behavior
Problem overview

                       Multiple
                                   Buffer and Storage are
Access manager etc
                       threads
                                    global shared objects
                                   All above can run in
Buffer Manager                      multiple parallel threads
                                   Needs thread control!

Storage Manager
                       ?




       File
Fine-grained control

Access manager etc                     From bottom to top:
                                       Physical storage is
                                        already controlled by OS
Buffer Manager
                                       Storage manager can use
                         ???


                                        simple SWMR due
                         SWMR           immutability on read
Storage Manager          concurency
                                       Buffer manager needs
                                        something else…

                         OS-based



       File
Fine-grained control

                     Multiple
                                 Global lock provides only
Access manager etc
                     threads
                                  safety
                                 No performance benefit!
Buffer Manager



Storage Manager
                     Locked!




       File
Deep down in the Buffer Manager

                                                      Underneath BM consists
                                                         of:
                                                         External interface
Access manager etc
                                                     

Buffer Manager
                     Buffer   Buffer Control Block
                                      list
                                                        Buffer Pool object
                      Pool
                                                        List of BufferControl
                                                         Blocks
                                     Pages
Storage Manager

                                                        Chunk of memory for
                                                         cached Pages
       File
Buffer Manager API
class KAIROSMOBILE_API CBufferManager
{                                                                    We can identify 3 groups:
  // ACTUAL API
  BM_RESULT readPage(TBSID tbsID, PAGEID pageNum, PAGEP&
retPage);
                                                                     read, write and page
  BM_RESULT writePage(TBSID tbsID, PAGEID pageNum);
  BM_RESULT fixPage(TBSID tbsID, PAGEID pageNum, PAGEP& retPage);
  BM_RESULT unFixPage(TBSID tbsID, PAGEID pageNum);
                                                                        pinning API
    // ALLOCATION API OF Storage Manager
    BM_RESULT allocPage( TBSID tbsID, PAGEID& pageID );
                                                                       Allocation API from
    BM_RESULT freePage( TBSID tbsID, PAGEID pageID );
                                                                        Storage manager
    // Unused API
    BM_RESULT checkPage(TBSID tbsID, PAGEID pageNum);
    BM_RESULT touchPage(TBSID tbsID, PAGEID pageNum);                  Unused part of API
    BM_RESULT invalidatePage(TBSID tbsID, PAGEID pageNum);

}
    // …
                                                                       Our goal is first group
                                                                       More on this later…
Existing algorithm
         fixPage                                     fixPage( pageId ):
                                                                // lookup page in BP
                                                                pageBcb = bp.lookup( pageId )
      lookup( page )                                            if pageBcb found:
                                                                            // in buffer
                                                                            return pageBcb.buf
         found?
                                                                // need to read
                                                                pageBcb = bp.getLRU()
      getLRU page                                               if pageBcb.isDirty: sm.flushPage( … )
                                                                sm.readPage( pageBcb.buf )
                                                                return pageBcb.buf
          dirty?       YES   flushPage
                                         not found
YES




        readPage
Race condition

                                      T1: Read N       T2: Read N

                                      Not found,
                                        read


                                                       Not found,
                         Reading...
                                                         read



                                          Reading...


                                         Read
                                       complete


                                                          Read
                                                        complete




Simple lock can’t solve race conditions in multiple requests, need another
solution.
New approach

 Provides per-request lock granularity
 Solves inconsistency
 But requires few more changes…
Now

                                       Existing BufferControl
                                        block structure
                                       Buffer Pool maintains set
       Buffer Pool                      of the BCB in linear and
                             page*
                             prev*
                                        LRU lists
BCB    BCB    BCB    BCB     next*
                           lruprev*    BCB contains
                           lrunext*
                              flags
                                        management
Page   Page   Page
                                        information for Page
                                        buffers
Changes

                                       Bcb flags have two more
                                        states: reading, waiting
                                       Bcb extended with the
       Buffer Pool
                             page*
                             prev*
                                        new field to refer a wait-
BCB    BCB    BCB    BCB
                             next*      object*
                           lruprev*
                           lrunext*        wait-object is sort of
                             flags
Page   Page   Page            wob           conditional variable

                            WOB
New algorithm

                                                                                              Starts with the local lock
                                       fixPage

                                        LOCK




                                                                                              Looksup page in BP…
                                    lookup( page )



                        YES            found?         NO         getLRU page
                                                                                                  If page found, check read
               reading?
                                                                    dirty?                         flag in BCB
                  wob
               assigned?
                              NO   assign wob
                                                                  writePage
                                                                                NO
                                                                                                    If read we are the first who
                                                                                                     yields to wait, setup and
                                                                                                     assign Wait-object
             mark (waiting)
                                                                 reset flags,
found
        NO                                                       set reading


                                                                                                    Wait for read to complete
                                                                                     not
              wait on (wob)                                        UNLOCK
                                                                                     found



               free wob
                                                                  readPage
                                                                                                    Free Wait-object
                UNLOCK
                                                                    LOCK
                                                                                                  Return page
                                           signal (wob)    YES    waiting?



                                                                 reset flags,
                                                                 set reading

                                                                   UNLOCK

                                       return
New algorithm 2

                                                                                              Starts with the local lock
                                       fixPage

                                        LOCK


                                    lookup( page )
                                                                                              Looksup page in BP …
                        YES            found?         NO         getLRU page                    If page not found, check
               reading?                                                                          dirty flag in BCB
                                                                    dirty?

                  wob
                                                                                                      Flush page
                              NO   assign wob

                                                                                                   Withdraw lock
               assigned?
                                                                  writePage
                                                                                NO
                                                                                               

found
        NO
             mark (waiting)
                                                                 reset flags,
                                                                 set reading
                                                                                                      Request read
              wait on (wob)                                        UNLOCK
                                                                                     not
                                                                                     found        Hold lock
               free wob
                                                                  readPage
                                                                                                  If waiting flag is set:
                UNLOCK
                                                                    LOCK
                                                                                                      Signal ‘wait complete’
                                           signal (wob)    YES    waiting?
                                                                                                  Reset flags
                                                                 reset flags,
                                                                 set reading
                                                                                                  Return page
                                                                   UNLOCK

                                       return
New algorithm 3

                                                                                              Note, only requests to
                                       fixPage

                                        LOCK


                                    lookup( page )
                                                                                               the page which is already
                        YES            found?         NO         getLRU page                   reading are put on hold
               reading?
                                                                    dirty?                    Also, withholding lock
                  wob
               assigned?
                              NO   assign wob
                                                                  writePage
                                                                                NO             around ‘read’ call allows
        NO
             mark (waiting)
                                                                 reset flags,
                                                                                               another threads to
                                                                                               proceed non-blocking
found                                                            set reading

                                                                                     not
              wait on (wob)                                        UNLOCK
                                                                                     found

                                                                  readPage
               free wob

                                                                    LOCK
                UNLOCK

                                           signal (wob)    YES    waiting?



                                                                 reset flags,
                                                                 set reading

                                                                   UNLOCK

                                       return
Time diagram

                            T1: Read N                      T2: Read N   T3: Read M

                            Not found,
                              read

                                                             Found,
               Reading...
                                                            "reading"


                                                                           Reading...


                               Read                                         Read
                                                    Waiting on Wob
                             complete                                     complete


                                Signal completion             Acquired




* Readers can proceed if they request different page and wait if page is
loading.
Summary of changes

 Extending Buffer Control Block with flags and WOB
  index field
 Waiting Object (sort of counted conditional variable)
  and fast-mutex cross-platform primitives
 Upgrade Buffer Manager algorithm
 Possible Buffer Manager API consolidation
API Consolidation

 Consistent BM API:             Currently:
    fixPage( id, flags )        readPage is same as:
    unfixPage( id )                 fixPage + copy + unfix
    flushPage( id )             writePage is actually
                                  flush
                                 + unused API
Alternatives

   Access manager etc                    Per thread buffer
                                          manager does not
                                          require anything of the
 Buffer
Manager
                  Buffer
                 Manager
                           Per thread     above
                                         Also can positively affect
                           SWMR
                                          thread cache fighting
   Storage Manager         concurency     (thrashing)
                                         Only requires SWMR
                                          lock on Storage Manager
                           OS-based



          File
Questions?

    -

Mais conteúdo relacionado

Último

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Destaque

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Mt bm1

  • 1. Multithreading aware Storage PATCH DESCRIPTION
  • 2. Goals  Make Storage and Buffering Managers multithreading-safe  Improve performance by allowing simultaneous operations  Provide flexible compile-time options to select optimal behavior
  • 3. Problem overview Multiple  Buffer and Storage are Access manager etc threads global shared objects  All above can run in Buffer Manager multiple parallel threads  Needs thread control! Storage Manager ? File
  • 4. Fine-grained control Access manager etc  From bottom to top:  Physical storage is already controlled by OS Buffer Manager  Storage manager can use ??? simple SWMR due SWMR immutability on read Storage Manager concurency  Buffer manager needs something else… OS-based File
  • 5. Fine-grained control Multiple  Global lock provides only Access manager etc threads safety  No performance benefit! Buffer Manager Storage Manager Locked! File
  • 6. Deep down in the Buffer Manager  Underneath BM consists of: External interface Access manager etc  Buffer Manager Buffer Buffer Control Block list  Buffer Pool object Pool  List of BufferControl Blocks Pages Storage Manager  Chunk of memory for cached Pages File
  • 7. Buffer Manager API class KAIROSMOBILE_API CBufferManager {  We can identify 3 groups: // ACTUAL API BM_RESULT readPage(TBSID tbsID, PAGEID pageNum, PAGEP& retPage);  read, write and page BM_RESULT writePage(TBSID tbsID, PAGEID pageNum); BM_RESULT fixPage(TBSID tbsID, PAGEID pageNum, PAGEP& retPage); BM_RESULT unFixPage(TBSID tbsID, PAGEID pageNum); pinning API // ALLOCATION API OF Storage Manager BM_RESULT allocPage( TBSID tbsID, PAGEID& pageID );  Allocation API from BM_RESULT freePage( TBSID tbsID, PAGEID pageID ); Storage manager // Unused API BM_RESULT checkPage(TBSID tbsID, PAGEID pageNum); BM_RESULT touchPage(TBSID tbsID, PAGEID pageNum);  Unused part of API BM_RESULT invalidatePage(TBSID tbsID, PAGEID pageNum); } // …  Our goal is first group  More on this later…
  • 8. Existing algorithm fixPage fixPage( pageId ): // lookup page in BP pageBcb = bp.lookup( pageId ) lookup( page ) if pageBcb found: // in buffer return pageBcb.buf found? // need to read pageBcb = bp.getLRU() getLRU page if pageBcb.isDirty: sm.flushPage( … ) sm.readPage( pageBcb.buf ) return pageBcb.buf dirty? YES flushPage not found YES readPage
  • 9. Race condition T1: Read N T2: Read N Not found, read Not found, Reading... read Reading... Read complete Read complete Simple lock can’t solve race conditions in multiple requests, need another solution.
  • 10. New approach  Provides per-request lock granularity  Solves inconsistency  But requires few more changes…
  • 11. Now  Existing BufferControl block structure  Buffer Pool maintains set Buffer Pool of the BCB in linear and page* prev* LRU lists BCB BCB BCB BCB next* lruprev*  BCB contains lrunext* flags management Page Page Page information for Page buffers
  • 12. Changes  Bcb flags have two more states: reading, waiting  Bcb extended with the Buffer Pool page* prev* new field to refer a wait- BCB BCB BCB BCB next* object* lruprev* lrunext*  wait-object is sort of flags Page Page Page wob conditional variable WOB
  • 13. New algorithm  Starts with the local lock fixPage LOCK  Looksup page in BP… lookup( page ) YES found? NO getLRU page  If page found, check read reading? dirty? flag in BCB wob assigned? NO assign wob writePage NO  If read we are the first who yields to wait, setup and assign Wait-object mark (waiting) reset flags, found NO set reading  Wait for read to complete not wait on (wob) UNLOCK found free wob readPage  Free Wait-object UNLOCK LOCK  Return page signal (wob) YES waiting? reset flags, set reading UNLOCK return
  • 14. New algorithm 2  Starts with the local lock fixPage LOCK lookup( page )  Looksup page in BP … YES found? NO getLRU page  If page not found, check reading? dirty flag in BCB dirty? wob  Flush page NO assign wob Withdraw lock assigned? writePage NO  found NO mark (waiting) reset flags, set reading  Request read wait on (wob) UNLOCK not found  Hold lock free wob readPage  If waiting flag is set: UNLOCK LOCK  Signal ‘wait complete’ signal (wob) YES waiting?  Reset flags reset flags, set reading  Return page UNLOCK return
  • 15. New algorithm 3  Note, only requests to fixPage LOCK lookup( page ) the page which is already YES found? NO getLRU page reading are put on hold reading? dirty?  Also, withholding lock wob assigned? NO assign wob writePage NO around ‘read’ call allows NO mark (waiting) reset flags, another threads to proceed non-blocking found set reading not wait on (wob) UNLOCK found readPage free wob LOCK UNLOCK signal (wob) YES waiting? reset flags, set reading UNLOCK return
  • 16. Time diagram T1: Read N T2: Read N T3: Read M Not found, read Found, Reading... "reading" Reading... Read Read Waiting on Wob complete complete Signal completion Acquired * Readers can proceed if they request different page and wait if page is loading.
  • 17. Summary of changes  Extending Buffer Control Block with flags and WOB index field  Waiting Object (sort of counted conditional variable) and fast-mutex cross-platform primitives  Upgrade Buffer Manager algorithm  Possible Buffer Manager API consolidation
  • 18. API Consolidation  Consistent BM API:  Currently:  fixPage( id, flags )  readPage is same as:  unfixPage( id )  fixPage + copy + unfix  flushPage( id )  writePage is actually flush  + unused API
  • 19. Alternatives Access manager etc  Per thread buffer manager does not require anything of the Buffer Manager Buffer Manager Per thread above  Also can positively affect SWMR thread cache fighting Storage Manager concurency (thrashing)  Only requires SWMR lock on Storage Manager OS-based File