summaryrefslogtreecommitdiff
path: root/ovsdb/row.h
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb: Prepare snapshot JSON in a separate thread.Ilya Maximets2022-07-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conversion of the database data into JSON object, serialization and destruction of that object are the most heavy operations during the database compaction. If these operations are moved to a separate thread, the main thread can continue processing database requests in the meantime. With this change, the compaction is split in 3 phases: 1. Initialization: - Create a copy of the database. - Remember current database index. - Start a separate thread to convert a copy of the database into serialized JSON object. 2. Wait: - Continue normal operation until compaction thread is done. - Meanwhile, compaction thread: * Convert database copy to JSON. * Serialize resulted JSON. * Destroy original JSON object. 3. Finish: - Destroy the database copy. - Take the snapshot created by the thread. - Write on disk. The key for this schema to be fast is the ability to create a shallow copy of the database. This doesn't take too much time allowing the thread to do most of work. Database copy is created and destroyed only by the main thread, so there is no need for synchronization. Such solution allows to reduce the time main thread is blocked by compaction by 80-90%. For example, in ovn-heater tests with 120 node density-heavy scenario, where compaction normally takes 5-6 seconds at the end of a test, measured compaction times was all below 1 second with the change applied. Also, note that these measured times are the sum of phases 1 and 3, so actual poll intervals are about half a second in this case. Only implemented for raft storage for now. The implementation for standalone databases can be added later by using a file offset as a database index and copying newly added changes from the old file to a new one during ovsdb_log_replace(). Reported-at: https://bugzilla.redhat.com/2069108 Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovsdb-server: Log database transactions for user requested tables.Dumitru Ceara2022-06-281-0/+1
| | | | | | | | | | | | | | | | | | | Add a new command, 'ovsdb-server/tlog-set DB:TABLE on|off', which allows the user to enable/disable transaction logging for specific databases and tables. By default, logging is disabled. Once enabled, logs are generated with level INFO and are also rate limited. If used with care, this command can be useful in analyzing production deployment performance issues, allowing the user to pin point bottlenecks without the need to enable wider debug logs, e.g., jsonrpc. A command to inspect the logging state is also added: 'ovsdb-server/tlog-list'. Signed-off-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovsdb: transaction: Incremental reassessment of weak refs.Ilya Maximets2021-11-041-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main idea is to not store list of weak references in the source row, so they all don't need to be re-checked/updated on every modification of that source row. The point is that source row already knows UUIDs of all destination rows stored in the data, so there is no much profit in storing this information somewhere else. If needed, destination row can be looked up and reference can be looked up in the destination row. For the fast lookup, destination row now stores references in a hash map. Weak reference structure now contains the table and uuid of a source row instead of a direct pointer. This allows to replace/update the source row without breaking any weak references stored in destination rows. Structure also now contains the key-value pair of atoms that triggered creation of this reference. These atoms can be used to quickly subtract removed references from a source row. During reassessment, ovsdb now only needs to care about new added or removed atoms, and atoms that got removed due to removal of the destination rows, but these are marked for reassessment by the destination row. ovsdb_datum_subtract() is used to remove atoms that points to removed or incorrect rows, so there is no need to re-sort datum in the end. Results of an OVN load-balancer benchmark that adds 3K load-balancers to each of 120 logical switches and 120 logical routers in the OVN sandbox with clustered Northbound database and then removes them: Before: %CPU CPU Time CMD 86.8 00:16:05 ovsdb-server nb1.db 44.1 00:08:11 ovsdb-server nb2.db 43.2 00:08:00 ovsdb-server nb3.db After: %CPU CPU Time CMD 54.9 00:02:58 ovsdb-server nb1.db 33.3 00:01:48 ovsdb-server nb2.db 32.2 00:01:44 ovsdb-server nb3.db So, on a cluster leader the processing time dropped by 5.4x, on followers - by 4.5x. More load-balancers - larger the performance difference. There is a slight increase of memory usage, because new reference structure is larger, but the difference is not significant. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Dumitru Ceara <dceara@redhat.com>
* ovsdb: row: Add support for xor-based row updates.Ilya Maximets2021-07-151-2/+4
| | | | | | | | | | | | This will be used to apply update3 type updates to ovsdb tables while processing updates for future ovsdb 'relay' service model. 'ovsdb_datum_apply_diff' is allowed to fail, so adding support to return this error. Acked-by: Mark D. Gray <mark.d.gray@redhat.com> Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* osvdb: Add some helpful comments.Ben Pfaff2018-12-031-1/+1
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovsdb: Weak references performance fixRodriguez Betancourt, Esteban2016-07-261-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prevents the cloning of rows with outgoing or incoming weak references when those rows aren't being modified. It improves the OVSDB Server performance when many rows with weak references are involved in a transaction. In the original code (dst_refs is created from scratch): old->dst_refs = all the rows that weak referenced old new->dst_refs = all the rows that weak referenced old and are still weak +referencing new + rows in the transaction that weak referenced new In the patch (dst_refs incrementally built): Old->dst_refs = all the rows that weak referenced old Ideally, but expansive to calculate: New->dst_refs = old->dst_refs - "weak references removed within this TXN" + +"weak references created within this TXN" What this patch implements: New->dst_refs = old->dst_refs - "weak references in old rows in TXN" + "weak +references in new rows in TXN" The resulting sets should be equal in both cases. We do some more optimizations: - If we know that the transactions must be successful at some point then, instead of cloning dst_refs we could just move the elements between the lists. - At that point we lost the rollback feature, but we aren't going to need it anyway (note that we didn't really touch the src_refs part). - The references in dst_refs must point to new instead than old. Previously we iterated over all the weak references in dst_refs to change that pointer, but using an UUID is easier, and prevents that iteration completely. For some more commentary, see: http://openvswitch.org/pipermail/dev/2016-July/074840.html Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Remove lib/list.h completely.Ben Warren2016-03-301-1/+1
| | | | | | | | All code is now in include/openvswitch/list.h. Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Rename struct list to struct ovs_listThomas Graf2014-12-151-4/+4
| | | | | | | struct list is a common name and can't be used in public headers. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move compiler.h to <openvswitch/compiler.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | | | The following macros are renamed to avoid conflicts with other headers: * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT * PRINTF_FORMAT to OVS_PRINTF_FORMAT * NO_RETURN to OVS_NO_RETURN Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Rearrange structures to better fit valgrind's memory leak heuristics.Ben Pfaff2012-03-281-2/+2
| | | | | | | | | | | | | valgrind's memory leak detector considers a pointer to the head of a memory block to be "definitely" a pointer to that memory block but a pointer to the interior of a memory block only "possibly" a pointer to that memory block. Open vSwitch hmap_node and list data structures can go anywhere inside a structure; if they are in the middle of a structure then valgrind considers pointers to them to be possible leaks. Therefore, this commit moves some of these from the middle of data structures to the head, to reduce valgrind's uncertainty. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Implement table uniqueness constraints ("indexes").Ben Pfaff2011-06-061-0/+6
|
* ovsdb: Add functions for formatting column sets and data in columns sets.Ben Pfaff2011-06-061-2/+3
| | | | These will be used for formatting error messages in an upcoming commit.
* ovsdb: Add support for weak references.Ben Pfaff2010-03-171-6/+28
|
* ovsdb: Get rid of "declare" operation.Ben Pfaff2010-02-081-1/+1
| | | | | | It's more elegant, and just as easy to implement, if we allow a "named-uuid" to be a forward reference to a "uuid-name" in a later "insert" operation.
* ovsdb: Add support for referential integrity in the database itself.Ben Pfaff2010-02-081-1/+8
|
* Initial implementation of OVSDB.Ben Pfaff2009-11-041-0/+139