From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id BC2443858426 for ; Sat, 7 Oct 2023 01:18:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC2443858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6c4a25f6390so1741726a34.2 for ; Fri, 06 Oct 2023 18:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696641494; x=1697246294; darn=sourceware.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=SSUxOYr/jJOaf6B0oHzdLaXNieYfIdIFjOppx+fWmL8=; b=TA4tCskIe8Ghytfx+VptgXFnnUCfRKSEX5LrdcdoMsX6aewWmHSu/GytR5K7zy+0OR s9Ui5l0Y/R0WueVzIoscwhwGWD2AKrc0e4UuPSsoMvjRqjAD5kM5tAf/tnitbQOw+oT4 paD+P0tleD6Vzq0LE2axtReUTNNuMD6rtxVWDxn/9yYT9VNV5fOn1uFs1sjxj97W9uHz 9/Oc0aE7hjnWKPnIjQpLFDVkDKM9AbwNAGlqKVQxm892rwUsuSyXuXWAEsNTg559dzu/ QZdn7VMi2UsNcIlzpEzQSRTt1FUiShqo7k5Qvw5A3DTvicgKQ8JRNvUzZW5EJeLRtKsl 50Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696641494; x=1697246294; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SSUxOYr/jJOaf6B0oHzdLaXNieYfIdIFjOppx+fWmL8=; b=h8iokyBgttYGyeY/FqCA9bO9lVi4gEqM0ZcI1b5ZRLRV/xuK16wlN9hY9qVFEm/IaP CnqMl7XEvRrCjSAKvSqgpaVmcKTWU7I2Dsyfshxcen3lJy+n642cZXo/0lnciIFiPkDH l7N8Him+iw2o5IBCVulAraC2GN70VG0vKT8R01oOEngmZ+TNT4mOrBH4WCueLie8cjKX 7EC7SJbzAacJITOVFWTBmaIdeuWBPOKdr+YcpYytEo5Pd8O0ZgFh+P1b8xLbOUHwV4cr dAqOgCQbAaSlVg0ewQXQK0f54pPMUD23tPvlReFT3ysWovSAEalR3yPajl3uowCt2zWE jZjA== X-Gm-Message-State: AOJu0Ywzi+dZ1XB1NNER8xqkrJ52ol1heXT4P7c50TbtfAYPYyM1IvOp 7LfeJf/0s3ojMP3J5HKIJXg+p4L+0ezmA9u5aqzw77my X-Google-Smtp-Source: AGHT+IGqGM0JKZgA+usXaFBByvnsbxFd9tofa/LxUvsRtNAIB/vcrvPGFlXwEMxLMdmpvCjg/DZQ+LpDfTyaUltMdoE= X-Received: by 2002:a05:6830:1e28:b0:6bb:1c30:6f3c with SMTP id t8-20020a0568301e2800b006bb1c306f3cmr9406062otr.0.1696641493918; Fri, 06 Oct 2023 18:18:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Panicz Maciej Godek Date: Sat, 7 Oct 2023 03:18:03 +0200 Message-ID: Subject: Re: Profiling Kawa code To: kawa Content-Type: multipart/alternative; boundary="0000000000008e6a0b0607162124" X-Spam-Status: No, score=4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPAM_URI,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: **** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000008e6a0b0607162124 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I did some profiling using VisualVM. First, it turned out that the slowdown came from a combinatorial explosion in my equality checking function. The complexity is now tamed, and the behavior is consistently smooth on the PC, but it still skips frames on Android. I made an optimization (memoization) to avoid repeated computation of the same thing in the rendering loop, because I was suspecting that to be the main source of complexity. According to the profiler the things did improve a bit, but the app still works noticeably slower than the one written in Java. The results of running a profiler show that: 13% of time is spent in java.lang.reflect.Method.invoke 24% are spent in various graphics API functions 8.4% is spent in gnu.lists.AbstractCharVector.hashCode 5.7% is spent in java.lang.Class.getDeclaredMethod 5.1% is spent in gnu.kawa.functions.IsEqual.match it seems that reflection uses over 18% of total time, and I think it would be great if this overhead could somehow be removed (I don't think that the design of GRASP requires any reflection, so it's possible that I'm misusing Kawa in some ways) pt., 6 pa=C5=BA 2023 o 11:16 Panicz Maciej Godek napisa=C5=82(a): > Hi, > As some of you may know, I've been developing a visual editor for > s-expressions. > Currently it's written 100% in Kawa (except some shell scripts that are > used for building and running). But I've noticed that it performs worse > than the earlier prototype, that was written in Java. > That's especially visible when I run it on my Android phone, whose > computational power is limited. But even on my super-fast laptop (9th gen > core i7) I see it occasionally choking. > > For example, I recently added a "visual stepper", and I ran it on the > Ackermann function. It generally runs smoothly, but around 1:28-1:35 it > suddenly slows down: > > https://youtu.be/1sB8fA-4S80?feature=3Dshared&t=3D87 > > So my question is, how do I approach profiling this code? > > --0000000000008e6a0b0607162124--