Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arch/version to cpu profiler #24658

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

travisdowns
Copy link
Member

  • debug api: wrong ID for cpu_profile_shard_samples
  • remove unused headers
  • utils: add arch library
  • cpu_profiler: expose the sample period
  • admin: include more info in cpu profile sample

@travisdowns travisdowns requested a review from a team as a code owner December 24, 2024 19:31
@travisdowns travisdowns changed the title td add arch version utils Add arch/version to cpu profiler Dec 24, 2024
@travisdowns travisdowns force-pushed the td-add-arch-version-utils branch from 1b69f68 to d339977 Compare December 24, 2024 19:34
@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Dec 24, 2024

Retry command for Build#60132

please wait until all jobs are finished before running the slash command



/ci-repeat 1
tests/rptest/tests/cpu_profiler_admin_api_test.py::CPUProfilerAdminAPITest.test_get_cpu_profile
tests/rptest/tests/cpu_profiler_admin_api_test.py::CPUProfilerAdminAPITest.test_get_cpu_profile_with_override

Copy link
Member

@StephanDollberg StephanDollberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some tests will need updating.

Is there a reason you didn't update the memory profiler as well?

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Dec 24, 2024

CI test results

test results on build#60132
test_id test_kind job_url test_status passed
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa6c-8e82-428e-8e6c-4178b3a23dd5 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa87-d0ac-497b-8cd9-de602b6e2b07 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa6c-8e82-49cd-b21d-00a779b61f71 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa87-d0a9-4cf9-aaf8-f066942dddb5 FAIL 0/1
rptest.tests.datalake.partition_movement_test.PartitionMovementTest.test_cross_core_movements.cloud_storage_type=CloudStorageType.S3 ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa87-d0ac-497b-8cd9-de602b6e2b07 FLAKY 4/6
rptest.tests.maintenance_test.MaintenanceTest.test_maintenance_sticky.use_rpk=True ducktape https://buildkite.com/redpanda/redpanda/builds/60132#0193fa87-d0a9-4cf9-aaf8-f066942dddb5 FLAKY 5/6
test results on build#60226
test_id test_kind job_url test_status passed
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile ducktape https://buildkite.com/redpanda/redpanda/builds/60226#019427b5-c7dd-4983-8fb6-f7b6c1254488 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile ducktape https://buildkite.com/redpanda/redpanda/builds/60226#019427cf-ee10-49cd-b1ad-96f34ab06566 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/60226#019427b5-c7de-4e14-ab05-e5ca1c377319 FAIL 0/1
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/60226#019427cf-ee0e-4928-bc72-1425979ebc5b FAIL 0/1
rptest.tests.random_node_operations_test.RandomNodeOperationsTest.test_node_operations.enable_failures=True.mixed_versions=True.with_tiered_storage=False.with_iceberg=False.cloud_storage_type=CloudStorageType.ABS ducktape https://buildkite.com/redpanda/redpanda/builds/60226#019427cf-ee0e-4928-bc72-1425979ebc5b FAIL 0/1
test results on build#61969
test_id test_kind job_url test_status passed
rptest.tests.cloud_storage_timing_stress_test.CloudStorageTimingStressTest.test_cloud_storage.cleanup_policy=compact.delete ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c90f-4102-a55f-5285e5adb6f8 FLAKY 1/2
rptest.tests.compaction_recovery_test.CompactionRecoveryTest.test_index_recovery ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c912-449b-b4a7-f7a2aef48c6e FLAKY 1/2
rptest.tests.compaction_recovery_test.CompactionRecoveryTest.test_index_recovery ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a2c-e15d-4e8c-b044-18fdf186b931 FLAKY 1/2
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c912-449b-b4a7-f7a2aef48c6e FAIL 0/20
rptest.tests.cpu_profiler_admin_api_test.CPUProfilerAdminAPITest.test_get_cpu_profile_with_override ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a2c-e15d-4e5c-888e-756b71de901c FAIL 0/20
rptest.tests.datalake.mount_unmount_test.MountUnmountIcebergTest.test_simple_unmount.cloud_storage_type=CloudStorageType.S3 ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c911-439f-85c1-2b740305e495 FLAKY 1/2
rptest.tests.log_compaction_test.LogCompactionTest.compaction_stress_test.cleanup_policy=compact.delete.key_set_cardinality=1000.storage_compaction_key_map_memory_kb=3 ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c910-4f7c-8009-ef06c990d8fc FLAKY 1/2
rptest.tests.log_compaction_test.LogCompactionTest.compaction_stress_test.cleanup_policy=compact.key_set_cardinality=1000.storage_compaction_key_map_memory_kb=3 ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c912-449b-b4a7-f7a2aef48c6e FLAKY 1/3
rptest.tests.partition_movement_test.SIPartitionMovementTest.test_shadow_indexing.num_to_upgrade=0.cloud_storage_type=CloudStorageType.ABS ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a28-c912-449b-b4a7-f7a2aef48c6e FLAKY 1/2
rptest.tests.timequery_test.TimeQueryTest.test_timequery.cloud_storage=False.batch_cache=False.spillover=False ducktape https://buildkite.com/redpanda/redpanda/builds/61969#01951a2c-e15d-4e8c-b044-18fdf186b931 FLAKY 1/2
test results on build#61976
test_id test_kind job_url test_status passed
rptest.tests.audit_log_test.AuditLogTestsAppLifecycle.test_recovery_mode ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b23-10bc-493c-a238-ff4bc2d3a888 FLAKY 1/2
rptest.tests.compaction_recovery_test.CompactionRecoveryUpgradeTest.test_index_recovery_after_upgrade ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b0e-c2d4-4679-b0a0-020bd6566f6f FLAKY 1/2
rptest.tests.compaction_recovery_test.CompactionRecoveryUpgradeTest.test_index_recovery_after_upgrade ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b23-10bd-4a95-a883-9a2f2712a9c3 FLAKY 1/2
rptest.tests.log_compaction_test.LogCompactionTest.compaction_stress_test.cleanup_policy=compact.key_set_cardinality=1000.storage_compaction_key_map_memory_kb=3 ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b0e-c2d7-4c0c-86aa-015589153d2b FLAKY 1/2
rptest.tests.node_pool_migration_test.NodePoolMigrationTest.test_migrating_redpanda_nodes_to_new_pool.balancing_mode=off.test_mode=TestMode.TIRED_STORAGE.cleanup_policy=compact.delete ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b0e-c2d6-40ac-adc7-9696b8a2cfe3 FLAKY 1/2
rptest.tests.partition_force_reconfiguration_test.PartitionForceReconfigurationTest.test_basic_reconfiguration.acks=-1.restart=True.controller_snapshots=False ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b23-10bd-4a95-a883-9a2f2712a9c3 FLAKY 1/2
rptest.tests.partition_move_interruption_test.PartitionMoveInterruption.test_cancelling_partition_move_x_core.replication_factor=1.unclean_abort=False.recovery=restart_recovery.compacted=False ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b23-10bd-4a95-a883-9a2f2712a9c3 FLAKY 1/2
rptest.tests.partition_movement_test.SIPartitionMovementTest.test_shadow_indexing.num_to_upgrade=0.cloud_storage_type=CloudStorageType.ABS ducktape https://buildkite.com/redpanda/redpanda/builds/61976#01951b0e-c2d7-4c0c-86aa-015589153d2b FLAKY 1/2
test results on build#62410
test_id test_kind job_url test_status passed
rptest.tests.compaction_recovery_test.CompactionRecoveryUpgradeTest.test_index_recovery_after_upgrade ducktape https://buildkite.com/redpanda/redpanda/builds/62410#01954811-cbaa-4720-b04e-345b42aeeba2 FLAKY 1/2
rptest.tests.partition_movement_test.SIPartitionMovementTest.test_shadow_indexing.num_to_upgrade=0.cloud_storage_type=CloudStorageType.ABS ducktape https://buildkite.com/redpanda/redpanda/builds/62410#01954814-84c0-42b8-9b11-943c7a4efbb3 FLAKY 1/2
rptest.tests.partition_movement_test.SIPartitionMovementTest.test_shadow_indexing.num_to_upgrade=0.cloud_storage_type=CloudStorageType.S3 ducktape https://buildkite.com/redpanda/redpanda/builds/62410#01954814-84c1-434c-acf3-411d53eb0eda FLAKY 1/2
rptest.tests.scaling_up_test.ScalingUpTest.test_scaling_up_with_recovered_topic ducktape https://buildkite.com/redpanda/redpanda/builds/62410#01954814-84c0-42b8-9b11-943c7a4efbb3 FLAKY 1/4

@travisdowns
Copy link
Member Author

Is there a reason you didn't update the memory profiler as well?

No it's coming, mostly just wanted to put this v1 up to see if there were concerns with the approach, etc.

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Jan 2, 2025

Retry command for Build#60226

please wait until all jobs are finished before running the slash command



/ci-repeat 1
tests/rptest/tests/cpu_profiler_admin_api_test.py::CPUProfilerAdminAPITest.test_get_cpu_profile
tests/rptest/tests/cpu_profiler_admin_api_test.py::CPUProfilerAdminAPITest.test_get_cpu_profile_with_override
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations@{"cloud_storage_type":2,"enable_failures":true,"mixed_versions":true,"with_iceberg":false,"with_tiered_storage":false}

@travisdowns travisdowns marked this pull request as draft January 6, 2025 19:17
@travisdowns travisdowns force-pushed the td-add-arch-version-utils branch from 5499d7a to b455fd6 Compare January 8, 2025 14:37
@travisdowns travisdowns requested a review from kbatuigas January 8, 2025 14:38
@travisdowns travisdowns force-pushed the td-add-arch-version-utils branch 2 times, most recently from cf884c4 to bfea0d9 Compare February 18, 2025 15:58
@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Feb 18, 2025

Retry command for Build#61969

please wait until all jobs are finished before running the slash command


/ci-repeat 1
tests/rptest/tests/cpu_profiler_admin_api_test.py::CPUProfilerAdminAPITest.test_get_cpu_profile_with_override

@StephanDollberg
Copy link
Member

We should also include the scheduling group id to name mapping such that we can reliably map the tags in pprof?

@travisdowns
Copy link
Member Author

@StephanDollberg

We should also include the scheduling group id to name mapping such that we can reliably map the tags in pprof?

Sure, but in another change? This series doesn't deal with SG changes at all, and in any case for that change I would assume that we just have the SG name directly in the json, attached to each sample, no need for a "mapping"?

@StephanDollberg
Copy link
Member

Sure, but in another change?

sure

I would assume that we just have the SG name directly in the json, attached to each sample, no need for a "mapping"?

Idk seems wasteful

@travisdowns
Copy link
Member Author

Idk seems wasteful

What alternative you considering? Using the numeric ID instead?

Wasteful in terms of bytes in the json? I feel like a typical sample is already 100s of bytes?

@StephanDollberg
Copy link
Member

What alternative you considering? Using the numeric ID instead?

Yes, basically just do the conversion in convert_to_pprof (or whatever other wrapper we will use that also invokes download-syms etc.)

Wasteful in terms of bytes in the json?

Bytes and compute/serialization.

I feel like a typical sample is already 100s of bytes?

Sure but that doesn't mean we can't save some bytes where it's not needed :) (basically the same discussion as to whether we include the arch/version in every stack/sample).

@travisdowns
Copy link
Member Author

travisdowns commented Feb 18, 2025

Sure but that doesn't mean we can't save some bytes where it's not needed :) (basically the same discussion as to whether we include the arch/version in every stack/sample).

I see those cases as quite different. Including the arch/version on every sample is the "wrong" schema, we'd just do that to avoid breaking the format, but you'd never want a schema like that if you designed it from scratch as logically the version/schema cannot vary among samples. So I think efficiency is a secondary concern there: actually having a schema that makes sense is the main driver.

This other thing is purely a case of efficiency I think? Scheduler groups are logically identified by their name (note [1]), so the natural schema is just to use the name as an attribute of the sample as I see it. Doing the mapping "works" but is unwieldy and so the savings should be pretty decent. Effectively it's some kind of ad-hoc compression algorithm. As for perf, not even sure if it's faster due to the need to do the lookup per [1]?

BTW you could apply the same sort of reasoning to individual frames which have a lot of duplication between samples and there I guess the savings would be significant (though frames are already fairly small as they are addresses, if they are in the main binary).


[1] Note that the ID is a hidden detail of the seastar impl and not accessible, so if we want to use an ID we will probably just reconstruct it at serialization time, i.e., arbitrarily assigning incrementing integers to scheduling groups as we find them. In seastar the assigned IDs depend on the order of "create sg" calls.

@StephanDollberg
Copy link
Member

This other thing is purely a case of efficiency I think?

Yeah that's true.

[1] Note that the ID is a hidden detail of the seastar impl and not accessible

Huh that is surprising. That does render the point moot indeed.

BTW you could apply the same sort of reasoning to individual frames which have a lot of duplication between samples and there I guess the savings would be significant (though frames are already fairly small as they are addresses, if they are in the main binary).

Right but here you'd actually have to do work to deduplicate them. If the id was accessible you could have just serialized that instead of transforming it to the string name first.

@travisdowns
Copy link
Member Author

If the id was accessible you could have just serialized that instead of transforming it to the string name first.

Yeah I had originally considered putting the ID, but then I realized the ID is not "fixed" and worse, it is not really accessible (sg ID is private only "name" and "short name" are exposed). It is still possible but we'd just need to generate IDs at serialization time.

kbatuigas
kbatuigas previously approved these changes Feb 19, 2025
Copy link

@kbatuigas kbatuigas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T.y. from Docs!

travisdowns and others added 11 commits February 27, 2025 10:54
id was set to cpu_profile_sample, should be cpu_profile_shard_samples.
A small header which exposes the architecture of the current process
as a constexpr value.

We will use this in the cpu_profiler in order to record the arch in
the output.

Includes a (very trivial) test.
Expose this so we can include it in the admin API result. This can be
useful to estimate how busy the reactor was, as we can calculate the
utilization based on the expected number of samples (at 100%
util) vs the observed number.
Change the output format of the cpu profiler API to include:

 - The CPU architecture
 - The version string
 - The wait_ms, if specified
 - The profiler sample period
 - The schema version of the API response

The first two of the above enable us to symbolize profiles directly from
the result without needing to know the version/arch and download
symbols separately.
Add an option to set the stack depth of the of spin loop in the
stress fiber, i.e., the spin loop will at the end of a recursive
call chain (not inlined) of depth N.

Good for stressing CPU proflier.
Update the attribute descriptions to be consistent with the rest of the
api-doc, by Kat Batuigas.

Co-authored-by: Kat Batuigas <[email protected]>
Let the stress fiber config be formatted, and print the config details
when the admin API endpoint is called.
Add some tests for the v2 format, and stress tests which try to
have something close to a worst-case scenario for CPU profiling, i.e.,
a large number of deep stacks.

In order to implement the stress test, we augment the stress fiber with
a mode which spins at a specific stack depth, i.e., calls N functions
before spinning so that the stack depth will be at least N (in practice
it will be somewhat more than N because there are other frames in the
stack beyond the ones added explicitly by the spinner).

Update existing DT tests for the new format.
When we get an ERROR log line which is allowed (i.e., should not fail
the test), we output this info at WARN log level. WARN log lines during
dt runs go to the "session log", i.e., the log that appears on stdout
so this often spams the console and session log with tons of benign
messages about allowed log lines.

Demote this to INFO instead. It will still show in the test log.
Add type annotations to some function parameters.
@travisdowns travisdowns force-pushed the td-add-arch-version-utils branch from 1bc1852 to e3a69a2 Compare February 27, 2025 13:56
@travisdowns
Copy link
Member Author

e3a69a2 is a pure rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants