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

GUI: Significant speedup #155

Merged
merged 6 commits into from
Dec 31, 2024
Merged

GUI: Significant speedup #155

merged 6 commits into from
Dec 31, 2024

Conversation

jdupak
Copy link
Collaborator

@jdupak jdupak commented Dec 31, 2024

No description provided.

@jdupak jdupak added the enhancement New feature or request label Dec 31, 2024
@jdupak jdupak force-pushed the gui-speedup branch 3 times, most recently from 16b40a1 to e08ef32 Compare December 31, 2024 21:41
@jdupak jdupak added this pull request to the merge queue Dec 31, 2024
Merged via the queue into master with commit 2a4153e Dec 31, 2024
11 checks passed
@ppisa
Copy link
Member

ppisa commented Dec 31, 2024

The build with Qt 5.15.8-2 on Debian leads to

../repo/emu/qtmips/QtMips-riscv/src/gui/windows/registers/registersdock.cpp:123:53: runtime error: member call on misaligned address 0xbebebebebebebebe for type 'const struct Registers', which requires 8 byte alignment
0xbebebebebebebebe: note: pointer points here
<memory cannot be printed>
../repo/emu/qtmips/QtMips-riscv/src/gui/windows/registers/registersdock.cpp:123:53: runtime error: member access within misaligned address 0xbebebebebebebebe for type 'const struct Registers', which requires 8 byte alignment
0xbebebebebebebebe: note: pointer points here
<memory cannot be printed>

Thread 1 "qtrvsim_gui" received signal SIGSEGV, Segmentation fault.
0x000055555674803a in RegistersDock::reload (this=0x614000046040) at ../repo/emu/qtmips/QtMips-riscv/src/gui/windows/registers/registersdock.cpp:123
123         setRegisterValueToLabel(pc, regs_handle->read_pc().get_raw());

@ppisa
Copy link
Member

ppisa commented Dec 31, 2024

Build with
Qt6 version: 6.4.2
Qt6 print support: 1
ends on the fault

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff783bd5a in __asan::AddressIsPoisoned (a=6817803684607009296) at ../../../../src/libsanitizer/asan/asan_mapping.h:379
379     ../../../../src/libsanitizer/asan/asan_mapping.h: No such file or directory.
(gdb) i s
#0  0x00007ffff783bd5a in __asan::AddressIsPoisoned (a=6817803684607009296) at ../../../../src/libsanitizer/asan/asan_mapping.h:379
#1  __asan::QuickCheckForUnpoisonedRegion (beg=6817803684607009296, size=7) at ../../../../src/libsanitizer/asan/asan_interceptors_memintrinsics.h:31
#2  0x00007ffff7848000 in __interceptor_memcpy (dst=0x5e9db4543159a210, src=0x7ffff7517d38, size=7)
    at ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
#3  0x00007ffff4dbb39c in QByteArray::insert(long long, QByteArrayView) () from /usr/lib/x86_64-linux-gnu/libQt6Core.so.6
#4  0x00005555565a2cef in QByteArray::append (this=0x7fffffffdea0, a=...) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qbytearray.h:222
#5  0x00005555565a2b94 in QByteArray::append (this=0x7fffffffdea0, s=0x7ffff7517d38 "QWidget", len=-1)
    at /usr/include/x86_64-linux-gnu/qt6/QtCore/qbytearray.h:219
#6  0x00005555565a2a82 in QByteArray::append (this=0x7fffffffdea0, s=0x7ffff7517d38 "QWidget") at /usr/include/x86_64-linux-gnu/qt6/QtCore/qbytearray.h:217
#7  0x00007ffff71bba10 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8  0x00007ffff71bb8d9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007ffff7fcf9ce in call_init (env=0x7fffffffdf78, argv=0x7fffffffdf68, argc=1, l=<optimized out>) at ./elf/dl-init.c:74
#10 call_init (l=<optimized out>, argc=1, argv=0x7fffffffdf68, env=0x7fffffffdf78) at ./elf/dl-init.c:26
#11 0x00007ffff7fcfab4 in _dl_init (main_map=0x7ffff7ffe2e0, argc=1, argv=0x7fffffffdf68, env=0x7fffffffdf78) at ./elf/dl-init.c:121
#12 0x00007ffff7fe5a80 in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#13 0x0000000000000001 in ?? ()
#14 0x00007fffffffe286 in ?? ()
#15 0x0000000000000000 in ?? ()

@ppisa
Copy link
Member

ppisa commented Dec 31, 2024

@jdupak the firs bad commit for Qt5 on my Debian system is

87d27b3 GUI: Ignore updates on hidden registers and batch update when shown

The Qt6 build in the Debug release seems to fail on address sanitizer much earlier

@jdupak
Copy link
Collaborator Author

jdupak commented Jan 1, 2025

@ppisa Does it work with the qt issue fix?

@ppisa
Copy link
Member

ppisa commented Jan 1, 2025

The Qt6 build configured

cmake ../QtMips-riscv -DCMAKE_BUILD_TYPE=Debug -DQT_VERSION_MAJOR=6 -DSANITIZERS:STRING=none -DDEV_MODE=true

results with

Starting program: /home/pi/repo/emu/qtmips/QtMips-riscv-build/target/qtrvsim_gui
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff23ff6c0 (LWP 5905)]
[INFO]  gui.main:       Started QtRVSim version 0.9.8.
[INFO]  gui.main:       Developed at FEE CTU (https://github.com/cvut/qtrvsim).
[New Thread 0x7ffff11ff6c0 (LWP 5906)]
[New Thread 0x7ffff09fe6c0 (LWP 5907)]

Thread 1 "qtrvsim_gui" received signal SIGSEGV, Segmentation fault.
0x00005555556e394c in machine::Registers::read_pc (this=0x7400630065006a) at /home/pi/repo/emu/qtmips/QtMips-riscv/src/machine/registers.cpp:25
25          return this->pc;
(gdb) i s
#0  0x00005555556e394c in machine::Registers::read_pc (this=0x7400630065006a) at /home/pi/repo/emu/qtmips/QtMips-riscv/src/machine/registers.cpp:25
#1  0x0000555555659c5a in RegistersDock::reload (this=0x555555cd0420)
    at /home/pi/repo/emu/qtmips/QtMips-riscv/src/gui/windows/registers/registersdock.cpp:123
#2  0x00005555556598f8 in RegistersDock::showEvent (this=0x555555cd0420, event=0x7fffffffd960)
    at /home/pi/repo/emu/qtmips/QtMips-riscv/src/gui/windows/registers/registersdock.cpp:85
#3  0x00007ffff77c8185 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#4  0x00007ffff7782a53 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#5  0x00007ffff69238b8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt6Core.so.6
#6  0x00007ffff77c4b93 in QWidgetPrivate::show_helper() () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#7  0x00007ffff77c4f9a in QWidgetPrivate::showChildren(bool) () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#8  0x00007ffff77c4b6f in QWidgetPrivate::show_helper() () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#9  0x00007ffff77c51b3 in QWidgetPrivate::setVisible(bool) () from /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6
#10 0x00005555556351be in MainWindow::start (this=0x7fffffffdb50) at /home/pi/repo/emu/qtmips/QtMips-riscv/src/gui/mainwindow/mainwindow.cpp:219
#11 0x00005555556313a9 in main (argc=1, argv=0x7fffffffdf78) at /home/pi/repo/emu/qtmips/QtMips-riscv/src/gui/main.cpp:38

The build with Qt6 seems to be linked correctly now, the ldd reports only Qt6 libraries.

Under valgrind, the qtrvsim_gui starts up to the open dialog, but it failed later anyway. Valgind invocation

valgrind --log-file=qtrvsim_gui.log --smc-check=stack --tool=memcheck --leak-check=full --gen-suppressions=all --track-origins=yes --leak-check=full --num-callers=25 target/qtrvsim_gui

Valgrind log attached

qtrvsim_gui.log.gz

The build on ce63bb0 and seems to be OK.

The application fails even when config files are deleted.

The valgrind long for above mentioned correct commit for Qt6 build

qtrvsim_gui-qt6-ok.log.gz

I can retest Qt5 on the master, but I expect that there is no change, i.e. fails.

The code is run under X11. Which can be difference. Even the correct Qt6 build has some strange lag at startup when windows frames are shown but they are drawn some four seconds latter. Under Valgrind, the lag is much longer and system seems to be busy for the whole time. I have not experienced the similar problem with Qt5 builds on my system. Debian 12.8 + some updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants