From 7616b0ea77df92c83252e89b1165c31b3214283d Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 17 Apr 2025 10:16:43 +0200 Subject: [PATCH] Document timing of task.create/delete in code --- snappea/decorators.py | 1 + snappea/foreman.py | 1 + 2 files changed, 2 insertions(+) diff --git a/snappea/decorators.py b/snappea/decorators.py index 477a7dc..809baa5 100644 --- a/snappea/decorators.py +++ b/snappea/decorators.py @@ -27,6 +27,7 @@ def shared_task(function): # No need for a transaction: we just write something (not connected to any other object, and we will never # touch it again). Counterpoint: if we'd have a transaction, we could distinguish between "wait for write # lock" and "actually write". + # observed timings: ~2.8ms, see also: https://www.bugsink.com/blog/snappea-design/#throughput kwargs.update(add_task_kwargs()) Task.objects.create(task_name=name, args=json.dumps(args), kwargs=json.dumps(kwargs)) diff --git a/snappea/foreman.py b/snappea/foreman.py index 237f55e..e2ea0d4 100644 --- a/snappea/foreman.py +++ b/snappea/foreman.py @@ -343,6 +343,7 @@ class Foreman: # (see 'counterpoint' in decorators.py for a counterpoint) # * delete-before-run is the implementation of our at-most-once guarantee with time_to_logger(performance_logger, "Snappea Task.delete()"): + # observed timings: ~1.5ms, see also: https://www.bugsink.com/blog/snappea-design/#throughput task.delete() self.run_in_thread(task_id, function, *args, **kwargs)