• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..08-Nov-2021-

expected/H08-Nov-2021-3726

sql/H08-Nov-2021-136

.gitignoreH A D08-Nov-202155 54

MakefileH A D08-Nov-2021516 2216

READMEH A D08-Nov-20212.4 KiB5041

setup.cH A D08-Nov-20219 KiB317186

test.cH A D08-Nov-20217.5 KiB266151

test_shm_mq--1.0.sqlH A D08-Nov-2021761 2014

test_shm_mq.controlH A D08-Nov-2021138 54

test_shm_mq.hH A D08-Nov-20211.2 KiB4618

worker.cH A D08-Nov-20216.7 KiB220101

README

1test_shm_mq is an example of how to use dynamic shared memory
2and the shared memory message queue facilities to coordinate a user backend
3with the efforts of one or more background workers.  It is not intended to
4do anything useful on its own; rather, it is a demonstration of how these
5facilities can be used, and a unit test of those facilities.
6
7The function is this extension send the same message repeatedly through
8a loop of processes.  The message payload, the size of the message queue
9through which it is sent, and the number of processes in the loop are
10configurable.  At the end, the message may be verified to ensure that it
11has not been corrupted in transmission.
12
13Functions
14=========
15
16
17test_shm_mq(queue_size int8, message text,
18            repeat_count int4 default 1, num_workers int4 default 1)
19    RETURNS void
20
21This function sends and receives messages synchronously.  The user
22backend sends the provided message to the first background worker using
23a message queue of the given size.  The first background worker sends
24the message to the second background worker, if the number of workers
25is greater than one, and so forth.  Eventually, the last background
26worker sends the message back to the user backend.  If the repeat count
27is greater than one, the user backend then sends the message back to
28the first worker.  Once the message has been sent and received by all
29the coordinating processes a number of times equal to the repeat count,
30the user backend verifies that the message finally received matches the
31one originally sent and throws an error if not.
32
33
34test_shm_mq_pipelined(queue_size int8, message text,
35                      repeat_count int4 default 1, num_workers int4 default 1,
36                      verify bool default true)
37    RETURNS void
38
39This function sends the same message multiple times, as specified by the
40repeat count, to the first background worker using a queue of the given
41size.  These messages are then forwarded to each background worker in
42turn, in each case using a queue of the given size.  Finally, the last
43background worker sends the messages back to the user backend.  The user
44backend uses non-blocking sends and receives, so that it may begin receiving
45copies of the message before it has finished sending all copies of the
46message.  The 'verify' argument controls whether or not the
47received copies are checked against the message that was sent.  (This
48takes nontrivial time so it may be useful to disable it for benchmarking
49purposes.)
50