mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Lower minumum batch size to 1 for background updates (#11422)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
parent
f25c75d376
commit
7f9841bdec
1
changelog.d/11422.bugfix
Normal file
1
changelog.d/11422.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Improve performance of various background database schema updates.
|
@ -82,7 +82,7 @@ class BackgroundUpdater:
|
|||||||
process and autotuning the batch size.
|
process and autotuning the batch size.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MINIMUM_BACKGROUND_BATCH_SIZE = 100
|
MINIMUM_BACKGROUND_BATCH_SIZE = 1
|
||||||
DEFAULT_BACKGROUND_BATCH_SIZE = 100
|
DEFAULT_BACKGROUND_BATCH_SIZE = 100
|
||||||
BACKGROUND_UPDATE_INTERVAL_MS = 1000
|
BACKGROUND_UPDATE_INTERVAL_MS = 1000
|
||||||
BACKGROUND_UPDATE_DURATION_MS = 100
|
BACKGROUND_UPDATE_DURATION_MS = 100
|
||||||
|
@ -20,6 +20,7 @@ import synapse.rest.admin
|
|||||||
from synapse.api.errors import Codes
|
from synapse.api.errors import Codes
|
||||||
from synapse.rest.client import login
|
from synapse.rest.client import login
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
|
from synapse.storage.background_updates import BackgroundUpdater
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
|
|
||||||
@ -150,9 +151,11 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
|||||||
"current_updates": {
|
"current_updates": {
|
||||||
"master": {
|
"master": {
|
||||||
"name": "test_update",
|
"name": "test_update",
|
||||||
"average_items_per_ms": 0.1,
|
"average_items_per_ms": 0.001,
|
||||||
"total_duration_ms": 1000.0,
|
"total_duration_ms": 1000.0,
|
||||||
"total_item_count": 100,
|
"total_item_count": (
|
||||||
|
BackgroundUpdater.MINIMUM_BACKGROUND_BATCH_SIZE
|
||||||
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
@ -203,9 +206,11 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
|||||||
"current_updates": {
|
"current_updates": {
|
||||||
"master": {
|
"master": {
|
||||||
"name": "test_update",
|
"name": "test_update",
|
||||||
"average_items_per_ms": 0.1,
|
"average_items_per_ms": 0.001,
|
||||||
"total_duration_ms": 1000.0,
|
"total_duration_ms": 1000.0,
|
||||||
"total_item_count": 100,
|
"total_item_count": (
|
||||||
|
BackgroundUpdater.MINIMUM_BACKGROUND_BATCH_SIZE
|
||||||
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
@ -230,9 +235,11 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
|||||||
"current_updates": {
|
"current_updates": {
|
||||||
"master": {
|
"master": {
|
||||||
"name": "test_update",
|
"name": "test_update",
|
||||||
"average_items_per_ms": 0.1,
|
"average_items_per_ms": 0.001,
|
||||||
"total_duration_ms": 1000.0,
|
"total_duration_ms": 1000.0,
|
||||||
"total_item_count": 100,
|
"total_item_count": (
|
||||||
|
BackgroundUpdater.MINIMUM_BACKGROUND_BATCH_SIZE
|
||||||
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
@ -267,9 +274,11 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
|||||||
"current_updates": {
|
"current_updates": {
|
||||||
"master": {
|
"master": {
|
||||||
"name": "test_update",
|
"name": "test_update",
|
||||||
"average_items_per_ms": 0.1,
|
"average_items_per_ms": 0.001,
|
||||||
"total_duration_ms": 2000.0,
|
"total_duration_ms": 2000.0,
|
||||||
"total_item_count": 200,
|
"total_item_count": (
|
||||||
|
2 * BackgroundUpdater.MINIMUM_BACKGROUND_BATCH_SIZE
|
||||||
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
|
@ -19,11 +19,11 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_do_background_update(self):
|
def test_do_background_update(self):
|
||||||
# the time we claim each update takes
|
# the time we claim it takes to update one item when running the update
|
||||||
duration_ms = 42
|
duration_ms = 4200
|
||||||
|
|
||||||
# the target runtime for each bg update
|
# the target runtime for each bg update
|
||||||
target_background_update_duration_ms = 50000
|
target_background_update_duration_ms = 5000000
|
||||||
|
|
||||||
store = self.hs.get_datastore()
|
store = self.hs.get_datastore()
|
||||||
self.get_success(
|
self.get_success(
|
||||||
@ -57,7 +57,7 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
# on the first call, we should get run with the default background update size
|
# on the first call, we should get run with the default background update size
|
||||||
self.update_handler.assert_called_once_with(
|
self.update_handler.assert_called_once_with(
|
||||||
{"my_key": 1}, self.updates.DEFAULT_BACKGROUND_BATCH_SIZE
|
{"my_key": 1}, self.updates.MINIMUM_BACKGROUND_BATCH_SIZE
|
||||||
)
|
)
|
||||||
|
|
||||||
# second step: complete the update
|
# second step: complete the update
|
||||||
|
Loading…
Reference in New Issue
Block a user