13
0
Commit Graph

1105 Commits

Author SHA1 Message Date
5d5d9b8114 add new API to PBD::Controllable, ::get_save_value()
Designed to allow derived classes to *save* a different value
than would be reported by ::get_value().

Specifically there so that slaved controls can save/restore
their *own* state, not the value that ::get_value() would
return.
2017-02-06 16:49:08 +01:00
715b9a959a Remove a JE addition to one of the qm-dsp source files (no longer needed) 2017-02-06 09:47:10 +00:00
5dabe45341 Some minor changes in preparation for building the newer Vamp plugins 2017-02-05 15:05:32 +00:00
db981b6085 more consistent terminology in a comment 2017-01-22 19:49:40 +01:00
8f8d0a70d8 Reap invalidation records 2017-01-20 13:54:03 +01:00
fbae5f5ffd Free dead request-buffers
This partially plugs a memory leak of event-loops.
2017-01-20 13:53:59 +01:00
Dobroslav Slavenskoj
04b515d535 syncing with upstream 2017-01-05 09:24:40 +00:00
Dobroslav Slavenskoj
5f0857620e Fixing LV2_SUPPORT #ifdefs 2017-01-05 09:24:40 +00:00
462c3eeb84 MIDI tracer actually changes the event-loop 2016-12-16 01:56:15 +01:00
6c88f339ca some further invalidation details:
Prevent double unref during when the EventLoop terminates:
deleting the ringbuffer deletes all requests, some of which may
contain stale invalidation

remove the buffer_map_lock, now that signals ref-count the IR.
2016-12-15 18:19:38 +01:00
529b91828d store InvalidationRecord in a Connection object and ref/unref it as appropriate 2016-12-15 16:36:50 +00:00
342c112ae3 add ::use_count() method to InvalidationRecord 2016-12-15 16:36:50 +00:00
cf4668a11e std::list::erase() needs a non-const iterator.;
at least for some versions of gcc.
2016-12-15 11:40:22 +00:00
714da0f68e and now with erase 2016-12-15 10:57:40 +01:00
71bfe79e2c C++98 compatible iterator erase 2016-12-15 10:40:45 +01:00
a95be76741 rework request invalidation
This kills 2 birds with 1 stone: Removes the necessity of locks
and makes call_slot() realtime safe (req->invalidation->requests list
push_back). On object destruction, the invalidation-record (IR) itself is
invalidated.

Invalidated IRs are pushed onto a trash-pool and deleted in the event-loop
of the invalidated object (GUI thread) once all requests that reference it
have been processed.

One last detail remains: PBD::signal connect should reference the IR
and disconnect unreference it. This will guarantee that signal emission
will not reference the IR while the pool trash is dropped.
2016-12-15 06:11:30 +01:00
62b06fa427 Add a trash pool for invalidation requests.
While EventLoop::invalidate_request() does invalidate request in the
request-list. It does *not* invalidate requests in the
per-thread-request-ringbuffer(s).
The invalidation record cannot be deleted in EventLoop::invalidate_request
see 6b5891a78f.
2016-12-14 22:39:25 +01:00
07bcdc7f0a NO-OP: re-indent 2016-12-14 22:39:22 +01:00
77845f6019 Atomically to invalidate request
Yet another slightly overkill approach, but it /may/ explain crashes.
2016-12-14 22:39:18 +01:00
7dbdf6cc6d Add some more invalidation debug messages. 2016-12-14 19:43:12 +01:00
6b5891a78f The threading anecdotes - Episode 7
When do_request() destroys the receiver object, the receiver will
free the invalidation record. So the IR needs to be removed from the list
before executing the request.

Invalid read of size 8
   at: AbstractUI<Gtkmm2ext::UIRequest>::handle_ui_requests() (abstract_ui.cc:242)
   by: BaseUI::request_handler(Glib::IOCondition) (base_ui.cc:141)
   by: sigc::bound_mem_functor1<bool, BaseUI, Glib::IOCondition>::operator()(Glib::IOCondition const&) const (mem_fun.h:2066)
   by: sigc::adaptor_functor<sigc::bound_mem_functor1<bool, BaseUI, Glib::IOCondition> >::deduce_result_type<Glib::IOCondition const&, void, void, void, void, void, void>::type sigc::adaptor_functor<sigc::bound_mem_functor1<bool, BaseUI, Glib::IOCondition> >::operator()<Glib::IOCondition const&>(Glib::IOCondition const&) const (adaptor_trait.h:89)
   by: sigc::internal::slot_call1<sigc::bound_mem_functor1<bool, BaseUI, Glib::IOCondition>, bool, Glib::IOCondition>::call_it(sigc::internal::slot_rep*, Glib::IOCondition const&) (slot.h:148)
   by: sigc::slot1<bool, Glib::IOCondition>::operator()(Glib::IOCondition const&) const (slot.h:643)
   by: cross_thread_channel_call_receive_slot(_GIOChannel*, GIOCondition, void*) (crossthread.cc:49)
   by: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5000.2)
   by: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5000.2)
   by: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5000.2)
   by: gtk_main (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.31)
   by: Gtkmm2ext::UI::run(Receiver&) (gtk_ui.cc:286)
   by main (main.cc:408)
 Addrd1b8 is 24 bytes inside a block of size 48 free'd
   at: operator delete(void*) (vg_replace_malloc.c:576)
   by: PBD::EventLoop::invalidate_request(void*) (event_loop.cc:98)
   by: sigc::internal::trackable_callback_list::~trackable_callback_list() (in /usr/lib/x86_64-linux-gnu/libsigc-2.0.so.0.0.0)
   by: sigc::trackable::notify_callbacks() (in /usr/lib/x86_64-linux-gnu/libsigc-2.0.so.0.0.0)
   by: ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay() (processor_box.cc:1757)
   by: ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay() (processor_box.cc:1760)
   by: ProcessorEntry::~ProcessorEntry() (processor_box.cc:251)
2016-12-14 18:46:01 +01:00
518c31eeb7 skip dead threads (if the event remains, it'll be cleaned up below) 2016-12-14 17:48:44 +01:00
036390f4c2 fix potential invalid lock 2016-12-14 17:31:31 +01:00
7a1ff7ce8f rework locking (fa07233a, 112fba182)
For now: use a single lock, which should fix all related crashes.
optimize (with less contended partial locks) if this works.
2016-12-14 13:43:20 +01:00
dd525d1613 release locks before deleting record 2016-12-14 02:25:13 +01:00
112fba182f amend prev commit 2016-12-14 00:51:40 +01:00
fa07233a17 mutex 'er up
Some overzealous locking to track down RequestObject related crashes.

bc0fa4d689 wrongly locked the current event loop's
request_invalidation_lock instead of the invalidation's list lock.

Also Abstract UI is able to delete requests concurrently with with
EventLoop invalidation.
e.g. PortManager::PortRegisteredOrUnregistered  and GlobalPortMatrixWindow
so the lock needs to be exposed.

If this solves various issues, mutexes should to be consolidated
(request_buffer_map_lock + request_invalidation_lock) and be chosen
such that there is as little contention as possible.
2016-12-13 23:47:07 +01:00
61693a318a Add LIBPBD_API to a function declaration
The new specialisation for ConfigVariable<float>::set_from_string() needs to be exportable (it gets used somehow by ARDOUR::SessionConfiguration).

If adding LIBPBD_API causes a problem for gcc, we could change it to LIBPBD_TEMPLATE_MEMBER_API
2016-12-08 17:29:49 +00:00
975f959adb For building with MSVC, std::strtof() didn't get introduced until VS2013
(use std::strtod() in earlier versions)
2016-12-08 13:57:23 +00:00
f521bdb9dc Fix another crash at exit. 2016-12-07 01:58:58 +01:00
7b1f97bffa fix parsing "-inf" in config variables
The default for export-silence-threshold is -INFINITY, written
as "-inf" (by cfgtool) into system_config. Yet parsing the config using
a std::stringstream results in "0" (due to bugs in various libc++).
2016-12-07 00:50:00 +01:00
b51321bd7d Make libpbd and evoral capable of standalone build
Just an update to slightly rotten wscripts, shouldn't be any changes during an
ardour build.  Motivation being a short development cycle for working on evoral
and/or its test suite.
2016-12-04 15:15:11 -05:00
bc0fa4d689 Fix mysterious crashes such as #7049
Fixes an issue with corrupted std::lists<> due to concurrent writes
to the invalidation list which eventually resulted in
EventLoop::invalidate_request() not invalidating requests.
Concurrency sucks rocks hard.
2016-11-24 09:02:47 +01:00
ed7b6fee0c Remove the MSVC 'poll()' emulation now that Ardour's stopped using poll() 2016-11-18 18:19:08 +00:00
cd5a319e48 fix mingw64 debug build 2016-11-17 12:58:28 +01:00
ed09a68f24 Fix for conflicting definition of _xgetbv with mingw-w64 >= 5
Simplify the #ifdef logic so it is easier to follow and add exceptions in the
future if necessary.
2016-11-10 15:23:43 +10:00
06700cb2f4 Allow to construct a XML tree from a text buffer 2016-10-29 19:57:43 +02:00
8519677a24 fix potentially crash-inducing race condition by removing event loops' x-thread channel from an event loop when it is destroyed 2016-10-17 14:48:15 -04:00
816f3bfb36 Use std::vector::reserve to improve performance of adding properties
The number of properties per node roughly corresponds to the number of members
of the class the node is representing and should be fairly low.

Use std::vector::reserve to prevent reallocation on insert for most node types,
there are exceptions like Region(~40 properties).

This seems worth it as part(maybe 1/10th of the total time) of saving a Session
is a combination of what occurs in "Create" and "Write" in this test.

Perf results before changes:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 30610 Max: 42656 Total: 376672 Avg: 37667 (37 msecs)
   Write : Count: 10 Min: 42804 Max: 54277 Total: 460455 Avg: 46045 (46 msecs)
   Read : Count: 10 Min: 70364 Max: 85484 Total: 750909 Avg: 75090 (75 msecs)
XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 164360 Max: 356995 Total: 3064482 Avg: 306448 (306 msecs)
   Write : Count: 10 Min: 308655 Max: 372953 Total: 3226707 Avg: 322670 (322 msecs)
   Read : Count: 10 Min: 517243 Max: 541839 Total: 5289950 Avg: 528995 (528 msecs)

Perf results after changes:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 30375 Max: 48253 Total: 431727 Avg: 43172 (43 msecs)
   Write : Count: 10 Min: 42553 Max: 49163 Total: 453353 Avg: 45335 (45 msecs)
   Read : Count: 10 Min: 70307 Max: 75987 Total: 734923 Avg: 73492 (73 msecs)
XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 154486 Max: 307856 Total: 2678989 Avg: 267898 (267 msecs)
   Write : Count: 10 Min: 304273 Max: 343274 Total: 3169158 Avg: 316915 (316 msecs)
   Read : Count: 10 Min: 496920 Max: 541394 Total: 5260410 Avg: 526041 (526 msecs)
2016-10-10 08:45:34 +10:00
e84fbfe6e5 Remove PropertyMap from XMLNode class
It appears that there is no performance benefit from storing properties in a
map for faster lookup or it is counteracted by the penalty of storing and
maintaining the additional data structure.

Timing results before changes with an optimized build:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 41293 Max: 63746 Total: 564448 Avg: 56444 (56 msecs)
   Write : Count: 10 Min: 42932 Max: 49221 Total: 453955 Avg: 45395 (45 msecs)
   Read : Count: 10 Min: 80160 Max: 84678 Total: 824506 Avg: 82450 (82 msecs)

XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 228759 Max: 420236 Total: 3587597 Avg: 358759 (358 msecs)
   Write : Count: 10 Min: 307095 Max: 348767 Total: 3205704 Avg: 320570 (320 msecs)
   Read : Count: 10 Min: 572400 Max: 657219 Total: 5959630 Avg: 595963 (595 msecs)

Perf results after changes:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 30610 Max: 42656 Total: 376672 Avg: 37667 (37 msecs)
   Write : Count: 10 Min: 42804 Max: 54277 Total: 460455 Avg: 46045 (46 msecs)
   Read : Count: 10 Min: 70364 Max: 85484 Total: 750909 Avg: 75090 (75 msecs)

XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 164360 Max: 356995 Total: 3064482 Avg: 306448 (306 msecs)
   Write : Count: 10 Min: 308655 Max: 372953 Total: 3226707 Avg: 322670 (322 msecs)
   Read : Count: 10 Min: 517243 Max: 541839 Total: 5289950 Avg: 528995 (528 msecs)
2016-10-10 08:45:34 +10:00
97752e6a51 Use references rather than copying containers in libpbd xml code
It is slightly surprising but there seems to be little difference to
performance with these changes. Possibly a slight improvement in "Create" test
with a large xml document(~5%).

Timing results before these changes with an optimized build using new XML perf tests:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 38656 Max: 63827 Total: 571228 Avg: 57122 (57 msecs)
   Write : Count: 10 Min: 43594 Max: 49279 Total: 459907 Avg: 45990 (45 msecs)
   Read : Count: 10 Min: 80247 Max: 84912 Total: 827207 Avg: 82720 (82 msecs)

XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 230706 Max: 456054 Total: 3850998 Avg: 385099 (385 msecs)
   Write : Count: 10 Min: 312322 Max: 353789 Total: 3264211 Avg: 326421 (326 msecs)
   Read : Count: 10 Min: 573556 Max: 610865 Total: 5951908 Avg: 595190 (595 msecs)

Timing results after these changes:

XMLTest::testPerfMediumXMLDocumentTiming
   Create : Count: 10 Min: 41293 Max: 63746 Total: 564448 Avg: 56444 (56 msecs)
   Write : Count: 10 Min: 42932 Max: 49221 Total: 453955 Avg: 45395 (45 msecs)
   Read : Count: 10 Min: 80160 Max: 84678 Total: 824506 Avg: 82450 (82 msecs)

XMLTest::testPerfLargeXMLDocumentTiming
   Create : Count: 10 Min: 228759 Max: 420236 Total: 3587597 Avg: 358759 (358 msecs)
   Write : Count: 10 Min: 307095 Max: 348767 Total: 3205704 Avg: 320570 (320 msecs)
   Read : Count: 10 Min: 572400 Max: 657219 Total: 5959630 Avg: 595963 (595 msecs)
2016-10-10 08:45:34 +10:00
a4b65212c9 Add test of pbd/xml++.h API performance with three file sizes
Generate, write and then read three Session like XML files to test the
performance of changes made to pbd/xml++.h API
2016-10-10 08:45:34 +10:00
4b2987d0f2 Add XMLNode::operator==/!=() for comparing XMLNode instances
Implemented to be able to test that when writing an XML document via XMLTree
and then reading back into another XMLTree the structure is equivalent as a
general API test of pbd/xml++.h to check for breakage when changing
implementation.
2016-10-10 08:45:34 +10:00
734a4c10e4 Change position of average in PBD::timing_summary and add msecs 2016-10-10 08:45:34 +10:00
116dace033 Add PBD::Timing::elapsed_msecs() as convenience API 2016-10-10 08:45:33 +10:00
Kamil Rytarowski
e426f0777a NetBSD ships with backtrace(3) in libexecinfo 2016-10-04 22:18:52 +02:00
Kamil Rytarowski
9d3077bd03 NetBSD uses statvfs for the functionality of statfs on Linux 2016-10-04 22:18:23 +02:00
b6c80153c3 add API to create [tar.xz] archives 2016-09-19 11:33:07 +02:00
02b7db03bd PBD::canonical_path will no longer throw so change test 2016-09-19 15:55:39 +10:00
569167a603 Move PBD::canonical_path to pbd/file_utils.h/cc and reimplement for Windows
This fixes the libpbd testCanonicalPathUTF8 and libardour
open_session_utf8_path unit tests

You can now have Sessions with localized names containing characters that
aren't in the system codepage on Windows.

It also fixes the issue where a Session would not open when it was moved into a
path with characters that aren't in the system codepage.

The only use case for calling canonical_path/realpath on the session path
AFAICT is for resolving relative paths that are passed via the command
line/terminal. I'm doubtful that works correctly on Windows because of
character encoding issues with the current API we use for that(not glib), so it
is slightly ironic that this issue was caused by an incorrect implementation of
a function that is not really necessary on Windows at this point in time.
2016-09-19 14:47:52 +10:00