Do Stockfish and the tablebase work together or independently? I use Arena GUI together with stockfish in engine games. I want to download a 6-piece tablebase but that is just a lot of work (and perhaps unnecessary). If I download the tablebase (syzygy), does stockfish work with it or just waits for the board to have 6-pieces and then the tablebase makes its moves?

Here is what I mean in more detail

Stockfish working with the tablebase

I assume I have the following position:

(Note: currently I am not talking about the best moves, just an example)

[Event "Computer Chess Game"]
[White "Stockfish 8"]
[Black "Wais Kamal"]
[Result "1-0"]
[SetUp "1"]
[FEN "2k4b/3r4/8/8/1Q1q4/8/4R3/2KB4 w - - 0 1 "]

1. Qxd4 Rxd4 1-0


Stockfish consults the tablebase about what happens after Qxd4 Rxd4 (without continuing to evaluate the rest of the line). If this line is winning it goes for it.

Stockfish working alone

Stockfish continues to play the game until six pieces are left on the board, then the tablebase makes the moves.

Which one of these actually takes place?
play the game until six pieces


Stockfish doesn't do that, that's not what tablebase is for. Briefly, tablebase boosts engine search well before six-men position reached on the board.

Let's do an exercise, add the board 5 pieces. Now you have 10 pieces on the board, and it's not something you can find in any tablebase. However, during the engine search whenever Stockfish trades down to 6 pieces, it can instantly use the tablebase information. The tablebase information gives Stockfish whether's the position is a win/loss/drawn without ever going down to anything like 5 pieces. Therefore, the search is faster and more efficient.

EDIT:

The relevant code is https://github.com/official-stockfish/Stockfish/blob/master/src/search.cpp:

// Step 4a. Tablebase probe
if (!rootNode &amp;&amp; TB::Cardinality)
{
    int piecesCount = pos.count&lt;ALL_PIECES&gt;();

    if (    piecesCount &lt;= TB::Cardinality
        &amp;&amp; (piecesCount &lt;  TB::Cardinality || depth &gt;= TB::ProbeDepth)
        &amp;&amp;  pos.rule50_count() == 0
        &amp;&amp; !pos.can_castle(ANY_CASTLING))
    {


TB::Cardinality is by default 6. Stockfish checks how many pieces, if it's no more than 6 it consults the tablebase information. Otherwise, regular search.