Repository navigation
Conversation
8a90ffb to
ec98125
Compare
|
I've been running load tests using the debug spans from this PR. Based on the investigation so far, I'm planning to add some more spans to this patch. I'll push all the changes once I'm confident that there isn't any value in monitoring deeper levels of each iteration. I'm going to convert this to a draft. |
ec98125 to
4afffd3
Compare
9587ea7 to
fd043e8
Compare
|
I've added some extra spans that provided valuable information during my testing and I've re-opened this PR. |
b93a4d2 to
c0caf88
Compare
There was a problem hiding this comment.
To my current knowledge, changes look mostly ok. Having traces in the scheduler and different components would make several things easier and possible, as we could base our decisions on actual data.
I'm not sure we can skip introducing the new task-sdk import in core.
Have you done any performance testing on what is the potential impact of these changes and debug mode enabling?
In the future, we could also add debug spans for the dag_processor or the triggerer or operations in the task-sdk.
Probably we would want to have an opt-in option list-like scheduler, dag processor that would enable debug only for scheduler and dag processor components.
|
@Miretpl Thank you for taking a look at this PR!
Yes, I have and and the difference is negligible. I don't expect people to have the spans turned on all the time, but to enable them after a performance incident so that they can investigate.
Yes, a filter list is a good idea if we add spans for mulitple components. |
Same. It is always good to know that potential debug mode will not degrade performance to the level that the environment will not meet certain performance criteria, especially if that is a production environment. |
c0caf88 to
1ae0900
Compare
1ae0900 to
b36a98b
Compare
9459d10 to
27c3612
Compare
|
@dstandish Please can you weigh in on this one? |
manish1337
left a comment
There was a problem hiding this comment.
Nice work on the spans, a couple of thoughts on the flag plumbing
|
@manish1337 Thank you for the review! I've addressed your comments. Please take a look and let me know what you think |
|
Thanks! Agreed on |
27c3612 to
0090783
Compare
0134c98 to
5be2774
Compare
a849f24 to
d28ad52
Compare
4ef2825 to
9ed78f0
Compare
9ed78f0 to
a97099a
Compare
This patch is adding a trace for every iteration of the scheduler loop and debug spans around all the major steps and queries.
Context
There is a config option for exporting debug traces.
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/config_templates/config.yml#L1504-L1513
We used to export random spans for multiple methods of the scheduler but these spans were never grouped together under a common trace and also didn't have any meaningful attributes. They were providing little to no benefit while they were actually adding more noise. Eventually, all such spans were removed and the config option was deprecated as unused but kept around in case we wanted to try a different approach in the future.
So far we only have traces for dag_runs but there are some operations across the project that are worth tracking with spans. The spans could help us pin-point the root cause of performance issues and come up with appropriate solutions.
There have been a lot of discussions around scheduler performance, task starvation, etc. with no solid way of consistently reproducing the issues or identifying the exact pain points. The spans added in this patch could be a good 1st step towards improving the scheduler.
In the future, we could also add debug spans for the dag_processor or the triggerer or operations in the task-sdk.
Current changes + examples
I've added a new function with a
start_as_current_spancall guarded by the debug traces flag so that we can enable and disable the new traces (disabled by default).The parent span for each iteration always starts as a root span and it has an attribute
airflow.scheduler.loop_iteration.idlewhich can help us distinguish the iterations that actually did some work. We can use it to filter the spans and find the interesting ones.Then we can sort by the longest first and start examining them
Not all iteration traces look the same. In the above example, this is the longest
2nd longest
3rd longest
And we are also exposing various internal values. I've only added attributes that are available at the moment of the span and avoided doing any calculations that will add more load to the system.
Testing
Apart from manual testing, I've added unit tests for the new
start_debug_spanfunction and an integration test that checks for certain spans that we can expect to consistently appear in every iteration.Was generative AI tooling used to co-author this PR?
Claude-code Opus 4.8
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.