From nobody Thu Jun 2 03:15:28 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4E7E919C7728 for ; Thu, 2 Jun 2022 03:15:46 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LDB3j4HmSz4Ybv for ; Thu, 2 Jun 2022 03:15:45 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-ot1-f45.google.com with SMTP id l9-20020a056830268900b006054381dd35so2593534otu.4 for ; Wed, 01 Jun 2022 20:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=TbA6f8Ur/+eIN8UnL9nNqAH8UZWARl3Od6wmFNMXki8=; b=yyDym6pESgW3VCEh6xmR4ZCLezlaxo9Qz93nfJCOwjuoETHTkLYY9JV3thdFKg1tjv RcisXuhI91OVQsUtmUuqZQfrSJUUU2qik3OTAY4fdpq8v+IL049c5BEkNXAVzyCVPdUl 7es/spwZSsdqZXDGQOXOw18JUTH8zcwTyewU9YSKxnH8KvWY5iPaVt2TYcUJDOS7g/ZV gmDVKCSiUCcxCoOlnXtbPOZKotqo0iythIzLQMcDXqc7Xr5wHFn/+H/jemmBtolsw99w R7QBRLq1GQbEZ9Ei5daiEoBPGw2DilgLAmM+c0pC2mrrhxzfRQkVgGSR2JEetygq56Hf xr4Q== X-Gm-Message-State: AOAM531UhIbwU16huHOICdAA+wUWkED4s5fHnTT7xjYrLE9SBadad3BZ FvNih1MQg4qteuKktYusU2QX6ZxOKP7fqrEy0SguyNqO+zg= X-Google-Smtp-Source: ABdhPJxI+P7Zr+pxPbR7PqotB/hYFQOhE+lggZ4nt542KOPvPHRVBiWPlDZ/ptoEfoEA86lz+iMnE9g+5drb66iCnYE= X-Received: by 2002:a05:6830:4c3:b0:60b:2c2a:7d4b with SMTP id s3-20020a05683004c300b0060b2c2a7d4bmr1254426otd.371.1654139738869; Wed, 01 Jun 2022 20:15:38 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 From: Alan Somers Date: Wed, 1 Jun 2022 21:15:28 -0600 Message-ID: Subject: Dtrace, Rust, and LLVM13 To: FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4LDB3j4HmSz4Ybv X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-1.02 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FREEFALL_USER(0.00)[asomers]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.210.45:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; NEURAL_SPAM_MEDIUM(0.98)[0.976]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.993]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.45:from]; MLMMJ_DEST(0.00)[freebsd-hackers]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; FREEMAIL_ENVFROM(0.00)[gmail.com]; TO_DOM_EQ_FROM_DOM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N The best way to profile a Rust program on FreeBSD is with Brendan Gregg's Flamegraph[1]. This is based on dtrace's ustack() function. It used to work great. However, Rust v1.56.0 is based on LLVM13[2] and now dtrace can't print user stacks anymore. For example, With Rust 1.55.0 libc.so.7`__je_malloc_mutex_prefork+0x124 libc.so.7`__je_arena_prefork7+0x73 libc.so.7`_malloc_prefork+0x15b libthr.so.3`0x392e4a8c4686 libthr.so.3`_fork+0x18 test-dad15ed382b075cf`nix::unistd::fork::h358225d652a86eab+0xe test-dad15ed382b075cf`test::test_unistd::test_fork_and_waitpid::hb93c7cdf2b79d680+0x36 test-dad15ed382b075cf`test::test_unistd::test_fork_and_waitpid::_$u7b$$u7b$closure$u7d$$u7d$::h329a121974ff9291+0x11 test-dad15ed382b075cf`core::ops::function::FnOnce::call_once::h2261827bcba63036+0x11 test-dad15ed382b075cf`test::__rust_begin_short_backtrace::hefb7644d11da2ff9+0xa test-dad15ed382b075cf`test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::hdaa0fb71aac8d97e+0x2f3 test-dad15ed382b075cf`std::sys_common::backtrace::__rust_begin_short_backtrace::h8bcc057a546c1087+0xce test-dad15ed382b075cf`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hf7d978d08be459d0+0x6a test-dad15ed382b075cf`std::sys::unix::thread::Thread::new::thread_start::h6b52ca0eca213387+0x2b libthr.so.3`0x392e4a8c3a7a With Rust 1.56.0 libc.so.7`__je_malloc_mutex_prefork+0x124 libc.so.7`__je_arena_prefork7+0x73 libc.so.7`_malloc_prefork+0x15b libthr.so.3`0x1106cebc6686 libthr.so.3`_fork+0x18 test-b377ad62cc9e0624`nix::unistd::fork::hbf1ed55b658aa870+0xa 0x8 0xcccccccccccccccc See? dtrace still prints the C part of the stack, but it only prints one or sometimes two frames of the Rust stack. I'm not a compiler guy, so I don't know how to fix it. I don't even know if the problem lies in Rust or dtrace. Would any of you smart people be able to help here? This is a pretty important feature for Rust development. -Alan [1] https://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html [2] https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1560-2021-10-21